javascript - Getting rid of Value attribute of a textBox when using clone method in jQuery -


I am having trouble on this form, I am working on whenever I add or refresh the page Values ​​still exist. I believe this is because the clone method copies the value attribute from the text box. Is there any way, when I add another text box, can I get rid of them?

  & lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; JQuery example & lt; / Title & gt; & Lt; Script type = "text / javascript" src = "jquery-1.4.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Function removeTextBox () {var childCount = $ ('p'). Keep track of the basic guidelines of the size () // paragraph // It should always be 2p if the user should not first remove if (childCount! = 2) {var $ textbox = $ ('# textbox') $ TextBox.detach ()}} function addTextBox () {var $ textbox = $ ('# textbox') var $ clonedTextBox = $ textbox.clone () //document.getElementById('textBox').setAttribute ('value', "$") $ Textbox.after ($ clonedTextBox)} & lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form id = method = "POST" verb = "http://cs.harding.edu/gfoust/cgi-bin/show" & gt; & Lt; P id = "textbox" & gt; Email: & lt; Input type = "text" name = "email" /> & Lt; Input type = "button" value = "X" onclick = "removeTextBox ()" /> & Lt; / P & gt; & Lt; P & gt; & Lt; A href = "javascript: addTextBox ()" & gt; Add another email & lt; / A & gt; & Lt; / P & gt; & Lt; Input type = "submit" value = "submit" /> & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

The following additional work should be done:

  var $ Clone textbox = $ textbox.clone (); $ ($ ClonedTextBox) .val ('');  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -