Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script type="text/javascript">
  5. $(document).ready(function(){
  6. // wrong method to bind events to
  7. // dynamically generated elements
  8. BindEvents();
  9. });
  10.  
  11. function BindEvents(){
  12. var selector = "#editArea input[type=text]";
  13. $(selector).focus(function(){
  14. $(selector).removeClass("classNameColor1");
  15. $(selector).addClass("classNameColor2");
  16. });
  17. $(selector).blur(function(){
  18. $(selector).removeClass("classNameColor2");
  19. $(selector).addClass("classNameColor1");
  20. });
  21. }
  22. </script>
  23. </head>
  24.  
  25. <body>
  26. <!-- In editArea div text boxes are added dynamically either from server side or from client side
  27. code to add textboxes dynamically is not written here -->
  28. <div id="editArea"></div>
  29.  
  30. </body>
  31. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement