onclick this jquery – How to bind onclick event to dynamically added HTML element with jQuery?

onclick this jquery using The click event occurs when an element is clicked. To trigger the onclick function in jQuery Example with demo.

onclick this jquery – How to get the ID of the clicked button using JavaScript / jQuery

The click() method triggers the click event. you can learn to how to call jQuery(this) from anchor tag onclick function.

jquery click function

$( "#selector_id" ).click(function() {
  alert( "Handler for .click() called." );

HTML Code:


<!DOCTYPE html>
    <meta charset="utf-8">
    <title>Bind onclick event to dynamically added element - www.pakainfo.com</title>
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script type="text/javascript">
      // Put the jQuery all the bellow code Here
    <p>Click the button below to dynamically add new items. You can remove it later.</p>
    <button>+ Add</button>
      <li>Tamilrokers NewLink</li>
      <li>Tamilrokers NewLink</li>
      <li>Tamilrokers NewLink</li>

jQuery Code:

        //Add product
          $("ul.example").append("<li>Tamilrokers NewLink <a href='javascript:void(0);' class='delete'>ร—</a></li>"); 
        //Delete product
        $(document).on("click", "a.delete" , function() {

how to call jQuery(this) from anchor tag onclick function?


<li><a onclick="upcommingMovie(this);" href="javascript:void(0);">New NewLink</a></li>

function upcommingMovie(el) {      
       jQuery("#tree ul li").removeClass("selected");

I hope you get an idea about jquery onclick function.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donโ€™t forget to share.