Reputation: 47
I need to select all divs with class="test" from a variable and put them into another div.
var all = xmlhttp.responseText;
var x = $(all > '.test'); <-- how to write correctly ?
$('.anotherdiv').prepend(x);
Upvotes: 0
Views: 70
Reputation: 74420
Using jQuery filter() method:
var x = $(all).filter('div.test');
Or using find():
var x = $(all).find('div.test');
Now it depends value of your string all
Upvotes: 1
Reputation: 318242
$('<div />', {html : all}).find('.test').prependTo('.anotherdiv');
Upvotes: 4