I have an unordered list with the elements and I want to add an item at the end. Here's the current code:
Initial list:
& lt; Ul id = "all" & gt; & Lt; Li & gt; Some text & lt; Input type = "button" class = "remove" value = "-" /> & Lt; / Li & gt; & Lt; Li & gt; Some text & lt; Input type = "button" class = "remove" value = "-" /> & Lt; / Li & gt; & Lt; / Ul & gt;
The code that removes the list item:
$ ("delete."). Click (function () {$ (this) .Parent.) Delete (); });
The code that adds a new list item:
$ ("# add"). Click (function () {$ ("# all" "+" some text "+" & lt; input type = \ "button \" class = \ "remove \" value = \ "- \" /> "+" & Lt; / li & gt; ");});
Button to add a new list item:
& lt; Input Type = "Button" id = "add" value = "add" />
When I click on the button, a new list is actually added to the list But clicking on the Remove button does not happen.
Bonus: " gt; & Lt; Replace "some text" with input type = "text" />
"and you will see that there will be a different distance between the two newly added input elements between the initial ones. (Note: Firefox 3.0.5 Using .5).
I think what you're after the new jQuery 1.3 features - See live events.
This works for me:
$ (". Remove") live ("click", function () {$ (this ) .Parent (.) Deletion ();});
Bonus:
I am also using FF 3.0.5, and I have only one place between the two text boxes. If you are between the second text box and the button, then I have to agree with faith and say that there is reason for the vacancy.
Comments
Post a Comment