I am using a plugin that creates an accordion using jquery. However, my jquery function is running before the dom has been manipulated and the div id I am targeting in my function has been created. Here is my function.
jQuery('#_Offer_Something').click(function(){
if( !confirm('Delete?') ) { //show confirm dialog
return false; //do nothing if cancel is clicked (prevent the browser from following clicked link)
}else{
window.location.replace("http://stackoverflow.com");
}
});
So basically this doesn’t work because the div doesn’t exist yet.
EDIT
In your specific case you can use: .on()
The above will act as the now deprecated jQuery
.live()method.Make sure you placed your jQuery
<script>tag before the</body>tag.