简体   繁体   中英

Ionic add tap/click event dynamically

I have a div that is added dynamically from a javascript framework. After this is done, I want to add an ionic click/tap handler to that specific div. How can I achieve this?

<ul ng-click=function(){}>
    <my_generated_div></my_generated_div>
</ul>

You can add an event listener using its ID or class:

document.getElementById("yourDivID").addEventListener("click", function(){
   //YOUR CODE
});

or if you have a reference of the object:

yourObjectReference.addEventListener("click", function(){
   //YOUR CODE
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM