Selector working only on one element.
I'm trying to create a new <div class="line"> when an <input type="text"> contained in the last <div class="line"> loses focus.
But new div blocks are created only when the an <input type="text"> in the first<div class="line"> loses focus. Please I need help urgently. Thanks.
This is my code:
- <script type="text/javascript">
- $(function() {
- $(':text:last').blur(function() {
- $('<div class="line"><span>data: </span><input type="text"/></div>')
- .appendTo($('#lineStack'));
- });
- });
- </script>
- </head>
- <body>
- <div id="lineStack">
- <div class="line">
- <span>data: </span><input type="text" />
- </div>
- </div>
-
- </body>