jQuery click on Appended Element not working

后端 未结 5 982

I have an array. I am getting data from Array and using it in jQuery Append to list. But when I am clicking on list item its only showing the last element.

var a         


        
5条回答
  •  误落风尘
    2021-01-29 05:00

    Can you try this ?

    var $list = "
    "+ firstVal +"

    " + "

    "+ secondVal +"

    "; $("#myDiv").append($list); $list.on('click', function(){ alert(thirdVal); });

提交回复
热议问题