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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -