Users Pricing

forum

Home Forums How to get the id of the element clicked using jQuery? – MindStick

How to get the id of the element clicked using jQuery?

Anand Pandey 2048 06 Jun 2017
<div class="main_div">
    <div id="inner_div">   
        <span id="d1" class="get_clicked">click to get id</span>
    </div>
</div>

 

 

How to get the id of the clicked element? 

The span which is present inside the inner_div will be having different ids because I will be loading the span from the model(MVC) using jquery ajax. So there will be 'n' number of span. All the span will have unique id. I want to get the id of the span which I click.

How to get the id of the span when clicked? How to do this using jQuery?


2 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md