javascript - add double click action in html using jquery -
i adding double click action every li in ol. code is:
<style> li:hover { cursor: pointer; background-color: yellow; } </style> <script> $(function() { $('#myol li').dblclick(function() { alert($(this).text()); }); }); function myclick() { $("#myol").append("<li>item</li>"); }; </script> </head> <body> <ol id="myol"> <li>item 1</li> </ol> <button type="button" onclick="myclick()">button</button> </body> it works after page loading. click button add new line in ul. style works double click action cannot work in added new line. there way add double click action adding style? or there way this?
try using on() in jquery
$('body').on('dblclick','#myol li', function() { alert($(this).text()); });
Comments
Post a Comment