4

Say I have this script

$.get('test.html', function(data){ //data }); 

How can I find a div with a specific class inside data??

1 Answer 1

4

Use data as the context argument to $(selector, context), like this:

$.get('test.html', function(data){ $("div.someClass", data) }); 
Sign up to request clarification or add additional context in comments.

6 Comments

alert($('div.someClass',data).html()) is working in chrome, but returning null in IE.
@tou - Is the HTML you're dealing with valid?
Well, it's a Sharepoint web page. Is .html() function nor supported in IE. Isn't JQuery supported in all major browsers??
@tou - If it's an entire webpage, you have have issues...it's reliant on creating a documentFragment which can vary between browsers if the content isn't valid for a .innerHTML call. What does $(data).html() give you in IE?
$(data).html() gives me blank. alert(data) gives me the HTML markup of the web page. So, is there no way to do what I want in IE?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.