javascript - Run function when cicking off a div thats Contenteditable -
i have table has couble od tds, tds contain divs allows user change value within it. if user presses enter function called make user has click away div function run. possible?
you can use blur event:
$('.edit-me').prop('contenteditable', true); $('.edit-me').on('blur', function() { console.log( $(this).text() ); }); table { width: 100%; } table td { width: 50%; } .edit-me { padding: 10px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table border="1"> <tr> <td><div class="edit-me"></div></td> <td><div class="edit-me"></div></td> </tr> <tr> <td><div class="edit-me"></div></td> <td><div class="edit-me"></div></td> </tr> </table>
Comments
Post a Comment