Jquery ajax retrieves only one div block from another page

I have a successful ajax request that can load all html content, now I only need to get a div tag that contains the identifier "data-today".

How to encode such a script?

+3
source share
2 answers

Take a look at this SOq:

Something like that:

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();
}
+4
source

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

if you want the text inside it

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

.text () gives text between html

<div> hello how are you </div>
+2
source

Source: https://habr.com/ru/post/1778894/


All Articles