1

I have a link like this:

 <a class="search_res_click" target="_blank" href="#">
 <div>
  // lot of stuff here
 </div>

 </a>

And I attached an event to all such links via following:

$(".search_res_click").click(function(e) {
    $(".search_res_click").children().css("opacity", "1");
    $(e).css("opacity", "0.5");
    console.log($(e));
});

The function of the event handler is to change the opacity of the clicked link. But when I am clicking on the link it is not changing the opacity.

Could you please tell me what I am doing wrong here.

1
  • 1
    e is an event, not the element itself. Use $(this) Commented Mar 10, 2015 at 12:57

1 Answer 1

5

Try this

$(this).css("opacity", "0.5");

or

$(e.currentTarget).css("opacity", "0.5");

because e is object not element

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.