click a link is not working after changing html simple code on jsfiddle.net

203 views Asked by At

i have a hidden div with a link has a class "myvideo" and a function to play video but testing first and found out that it's not working after grabbing new data from the hidden div to the above div just click the upper red circle in Africa and try the video link (circles are positioned anywhere just for demonstration)

I'm loading just the qjeury file and my js file that contain all data in the next link

online code http://jsfiddle.net/vXPPF/

2

There are 2 answers

0
jk. On BEST ANSWER

The click handler is not bound because the div is hidden (not in the dom) on page load. Change it to:

 $(document).on("click", "a.myvideo", function(e) {
    e.preventDefault();
    alert("test");
});

New fiddle: http://jsfiddle.net/vXPPF/1/

jquery on: http://api.jquery.com/on/

2
MDEV On

Line should be:

$("a.myvideo").live('click',function(e){