Event binding with jquery live() function -


first here code:

html:

<div id="foreground">     <button type="button" id="go">start</button> </div> <div id="background">     <p>you on background</p> </div> 

js:

$(function () {     $("#go").click(function (e) {         var $q = $(this);         var $vazy = $('<button type="button" id="vazy"> vazy </button>');         var $loc = $('<input type="text" id="placename" placeholder="location"/>');          $vazy.insertafter($q);         $loc.insertafter($q);         $q.hide();          e.stoppropagation();      });      $("#vazy").live("click", function () {         alert('k');         //$("#foreground").hide();         //$("#background").show();     });  }); 

css:

#background {     display: none; } 

jsfiddle...

the problem @ line 15 button id #vazy seems not respond click event live binding. missing something?

thanks response :)

try this

    $("body").on("click","#vazy" function () {     alert('k');     //$("#foreground").hide();     //$("#background").show(); }); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -