Hi I'm trying to get the IDs of all DIVs, inside another HTML File, with a specific Class. To load the file I use:
$.get("blocks.html", function(data) {
//here I don't know how :)
});
Now what I'm looking for ist something like this:
data.$('.block').each(... the rest is no problem
so that I use the jQuery selectors not on my page code but instead inside the contend of the data variable. Thanks for help!
try:
Try this:
If your 'data html' containing element is a '.block', look at @undefined's answer
The answer really depends on what the responseText looks like that is being returned from the GET request. Based on that you would have to wrap it or not.
With Parent
If the response is nested inside of a parent tag.
Response Mark Up:
JavaScript:
Without Parent
If the response does not have a parent node wrapping the content, you would need to add the parent node or use filter.
Response Mark Up:
JavaScript:
or
Getting the ids
You can than use
map()
oreach()
onhtmlFiltered
to get the ids.With
each()
With
map()