Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <script type="text/javascript">
- $(document).ready(function(){
- // wrong method to bind events to
- // dynamically generated elements
- BindEvents();
- });
- function BindEvents(){
- var selector = "#editArea input[type=text]";
- $(selector).focus(function(){
- $(selector).removeClass("classNameColor1");
- $(selector).addClass("classNameColor2");
- });
- $(selector).blur(function(){
- $(selector).removeClass("classNameColor2");
- $(selector).addClass("classNameColor1");
- });
- }
- </script>
- </head>
- <body>
- <!-- In editArea div text boxes are added dynamically either from server side or from client side
- code to add textboxes dynamically is not written here -->
- <div id="editArea"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement