Quantcast
Channel: How to get id of an element in jQuery? - Stack Overflow
Browsing index pages (4 articles)
↧

How to get id of an element in jQuery?

I am new to jQuery and I am currently trying to get id of an element that has been clicked in the page.As far as I have read, I know that we can get an id of current element by using...

View Article


Answer by dotty for How to get id of an element in jQuery?

As Jason P pointed out in the comments, you're binding the .click() event to the $(document) so all references to $(this) will refer to the $(document). Since you're requesting the id of $(document)...

View Article


Answer by Arend for How to get id of an element in jQuery?

It's because $(this) is referring to document (what the event is bound to). The event.target parameter in the callback refers to the element that was clicked. If you want to use this in combination...

View Article

Answer by Mr X for How to get id of an element in jQuery?

<script>$(document).ready(function() { $(".well").mouseenter(function(e) { alert($(this).attr("id")); }); });</script><div class="container"><h2 class="text-info">...

View Article
Browsing index pages (4 articles)


Latest Images