Frank
Frank

Reputation: 33

JQuery, use selectors on page that is loaded into a variable

I'm writing a greasemonkey script with some JQuery in it.

I load a number of pages into variables. I use the $.get to get the pages in the variables/array. That works fine.

Now I'am wondering how I can extract data from pages that are stores in the variables by using jquery selectors.

What I want to do is write stuff like this:

mypages[i].(".foo a").each(function( index ) {...});

Upvotes: 1

Views: 62

Answers (1)

Josh E
Josh E

Reputation: 7432

What you really want to do is write stuff like this: $(mypages[i]).find(".foo a").each(...)

the jQuery object is very non-discriminatory. It will accept just about anything and convert it into a jQuery-like object, so assuming that mypages[i] is either an HTML string, jQuery object, or DOM Element, that should do it for ya

Upvotes: 3

Related Questions