jQuery. How to get ID of clicked element




When I wanted to get the ID of clickable element using jQuery, I have found out that I don't remmember such a simple thing. I had to look for it. And I've found it 🙂

I had buttons with class "phonebtnCall" and some IDs. I wanted to know which of buttons was clicked.

 

<span id="smth1" class="phonebtnCall">Button 1<span> 
<span id="smth2" class="phonebtnCall">Button 2<span> 
<span id="smth3" class="phonebtnCall">Button 3<span> 
....
    $('.phonebtnCall').click(function () { 
        $id = this.id; 
        alert($id);
    })

 




Yandex.RTB R-A-454402-1

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment





MarkiMarta.com. Notes of web-specialist
Since 2009
18+