4

I have a succeed ajax request that can download the whole html contents, now I only need to get a div tag which contains id "data-today".

How to code such a script?

1
  • @user , did you append that html to dom already ??? Commented Dec 7, 2010 at 4:21

2 Answers 2

5

Take a look at this SOq:

Something along these lines:

success: function(data) {
   //create jquery object from the response html
   var $response=$(data);
   //query the jq object for the values
   var dataToday = $response.find('#data-today').text();
}
Sign up to request clarification or add additional context in comments.

1 Comment

kool , this will take care eventhough html is not attached to DOM..+1///
2

$('#data-today').html() if you want all the html // this out puts

if you want text inside it

$('#data-today').text() // this gives hello how are you

.text() gives the text in between html

<div> hello how are you </div>

1 Comment

@user my answer will work if you append the results to dom already. icyrock answer will get you that div results from the response.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.