HTML inside of external jQuery function not working -


this little hard me explain. bare me. have external javascript file loads html within div on html page:

$(window).load(function(){ $('img#madhere').click(function(e) {     e.preventdefault();   $('#extras').html('<ul class="animated flash"><li class="drop"><a id="infobutton" class="scroll" href="#bottomcontent"></a><div class="dropdowncontain"><div class="dropout"><ul><li><a id="show_madhere_info" href="">info</a></li><li><a id="show_madhere_credits" href="">credits</a></li><li><a id="show_madhere_trivia" href="">trivia</a></li><li><a class="twits" href="https://twitter.com/share?text=check%20out%20%22were%20all%20mad%20here%22%20on%20jick%20pictures&url=http%3a%2f%2fwww.jickpictures.com" target="_blank">twitter</a></li><li><a class="facebooker" href="https://www.facebook.com/dialog/feed?app_id=19884028963&ref=share_popup&link=http%3a%2f%2fvimeo.com%2f58261368&redirect_uri=http%3a%2f%2fvimeo.com%2f58261368%3fclose" target="_blank">facebook</a></li><li><a class="tuber" href="http://youtu.be/tfht5bgvolu" target="_blank">youtube</a></li><li><a class="vimeos" href="https://vimeo.com/58261368" target="_blank">vimeo</a></li><li><a class="reddits" href="http://www.reddit.com/submit" onclick="window.location = "http://www.reddit.com/submit?url=" + encodeuricomponent(window.location); return false" target="_blank">reddit</a></li></ul></div></div></li></ul>');     }); });  

it loads fine exception of links working. links require yet external javascript file new function when links clicked.

$(document).ready(function(){         $("#show_madhere_info").click(function() {             $("div#modal").addclass("show"); 

my problem jquery function showing "show_madhere_info" div not work. instead reverts "href" link makes page reload.

<a id="show_madhere_info" href="">info</a> 

it's can't recognize div html inside of jquery function. make sense? can here make links work after content loads previous jquery function?

dynamically inserted elements require use of .on() function , won't work using standard .click() method.

try using this:

$(document).on('click', $("#show_madhere_info"), function(e) {    e.preventdefault(); //stop usual href action         ...  } 

also make sure using latest version of jquery 1.9.x


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -