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

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -