javascript - Find elements inside Data object of jQuery .get() -


i thought easier find :)

$.get('/page.html', function(data) {     //get contents of class="contents" }); 

i can't seem find out how that.

i this...

$.get('/page.html', function(data){    var $page = $(data)    var $contents = $page.filter('.contents'); /* reference .contents */    /* more stuff here        ....      */ }); 

have @ accepted answer so: get html of div element returned .get jquery

if structure of returned content uncertain (to need use .find() due .contents being descendent, perform check , run .filter() or vice versa.

example:

$contents = $page.filter('.contents'); if($contents.length == 0) {    $contents = $page.find('.contents'); } 

just thought based on comments posted in other answers.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -