Unable to use "this + ' div.someclass'" in jquery -


why working:

$('.btn').on('click', function(e) {     e.preventdefault();     $('.btn div.custom').html('<i class="check"></i>'); }); 

but not? :

$('.btn').on('click', function(e) {     e.preventdefault();     $(this + ' div.custom').html('<i class="check"></i>'); }); 

how can combine additional selectors? how accomplish in jquery?

use .find() select descendant elements

$('.btn').on('click', function(e) {     e.preventdefault();     $(this).find('div.custom').html('<i class="check"></i>'); }); 

or use context,

$('.btn').on('click', function(e) {     e.preventdefault();     $('div.custom',this).html('<i class="check"></i>'); }); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -