javascript - jquery - how can I select element after '.first()' using? -
how can select html tag after using jquery function called .first() ?
html
<html> <head> </head> <body> <div> <a> <img id="#hello"> </a> </div> <div></div> </body> </html> js (jquery)
var elemfirst = $(div).first(); var selectimg = elemfirst.$('img#hello'); // var selectimg = elemfirst.find('img'); <- working want select manual selectimg.addclass('some-css'); with respect
you can use $('child','parent') selector,
var elemfirst = $('div').first(); var selectimg = $('#hello',elemfirst); //or $('img',elemfirst); also, id has #, should id="hello".
if need keep value in id, use
var selectimg = $('img[id="#hello"]',elemfirst);
Comments
Post a Comment