I am creating more than 1 <a href="#"></a>
elements dynamically. The id
attribute is also dynamically assigned. Like <a href="#" id='delete"+id+"'></a>
. ID will becomes like delete01, delete02, ...
I want to call a function when clicking any one of these element. I just know,
$("#someId").click(this.someFunction());
calls the function, when the element with the ID someId
clicked.
The generated HTML looks like,
<a id="delete26" href="#" class="delete">Delete</a>
<a id="delete27" href="#" class="delete">Delete</a>
<a id="delete28" href="#" class="delete">Delete</a>
The JavaScript code that generates the above html looks like,
html += "<a class='delete' href='#' id='delete"+post.id+"'>Delete</a>";
Here, my ID's were dynamically generated. So, how shall i call a function when any one of the element got clicked.
Any suggestions!!!
Thanks!