Is it possible to use a :selector
with the following in jQuery?
$('.galler_attr').bind('click', function() {
$(this:first-child).css('color', 'red');
});
No. You're trying to mix the function context with a string.
Use this
as the context of the selector or call find()
on $(this)
to search within the DOM scope of the element. Either
$('.galler_attr').bind('click', function() {
$(this).find(':first-child').css('color', 'red');
});
or this (which resolves to the above internally):
$('.galler_attr').bind('click', function() {
$(':first-child', this).css('color', 'red');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With