How can we attach a Jquery function to a div that has been appended after the page was loaded, without any event being triggered.
In the example below defaultTab-28 is the div that has been appended later to the page.
<a href="javascript:toggleDiv('defaultTab-28')"
and now I want to use toggle function on the "defaultTab-28" div like
function toggleDiv(divId){
$("#" + divId).toggle();
}
If I use .delegate() or .on() I will have to specify the event like click etc, but in this case event trigger is not necessary.
Edit: to be a more precise:
I know using inline JS is not good when using JQuery, I could have used button click function from JQuery, but my question is : Is there any function like .on or .delegate to assign a function without an event
- I have added a div to an existing page
- When anybody clicks the tag I want the div that is passed to the javascript function which here is my div to use jquery toggle , but because this div is added later it cannot bind to toggle function