1

I have below code

         $('li').click(function(e){ 
         e.preventDefault();
         $(this).addClass("active1");

     // $(this a).addClass("acolor");  // I am trying  this

});;

Anchor tag is inside li tag and on click of li I want to change color of a text - which is there in css in .acolor class

in this I am getting li, and I want to get a tag.

Any help will be appreciated !! Thanks

CodeWithCoffee
  • 1,896
  • 2
  • 14
  • 36
  • I found the duplicate by searching for [`[jquery] find element inside this`](http://stackoverflow.com/search?q=%5Bjquery%5D+find+element+inside+this), which let me to http://stackoverflow.com/questions/10604251/call-elements-inside-this . – Felix Kling Feb 09 '17 at 06:30

1 Answers1

1

Use find() method.

$(this).find('a').addClass("acolor");

Or provide this as the context in the jQuery method.

$('a', this).addClass("acolor");
Pranav C Balan
  • 113,687
  • 23
  • 165
  • 188