Jump to content

add on input box after .click function?

Recommended Posts

<!doctype html><html lang="en"><head>  <meta charset="utf-8">  <title>To do list</title><link href='http://fonts.googleapis.com/css?family=Arvo:400,700,400italic,700italic' rel='stylesheet' type='text/css'>    <h1>To Do List</h1>    <style>button {margin-left: 30px;}h1 {font-family:'Arvo', slab-serif;  font-size: 25pt;   margin-left:30px;}  div {    display: none;    margin-left: 30px;    padding:5px; <!--to give space between each button-->  }  p {    font-weight: bold;    background-color: #fcd;  }</style>  <script src="https://code.jquery.com/jquery-1.10.2.js"></script></head><body> <button>Add</button><div>  <form>    <input type="text">    <button>Completed</button>  </form></div> <script>function add() {  $( "div" ).show( "fast" );}$( "button" ).click(function(){    $("div").append("$("input"); $( "form" ).submit(function( event ) {  if ( $( "input" ).val() === "yes" ) {    $( "p" ).show( 4000, function() {      $( this ).text( "Ok, DONE! (now showing)" );    });  }  $( "div" ).hide( "fast" );   // Prevent form submission  event.preventDefault();});</script> </body></html>
It's not javascript but I was hoping to get a feedback with the problem I have.
I'm trying to make it so that everytime I click "add" button, input box adds on.
I used .append but not working at all.
any suggestions??
Link to post
Share on other sites

1) Learn how to PROPERLY use html, and where html elements can and cannot go, AND then validate.


2) Learn how to PROPERLY use Jquery, and how apply events correctly for especially jquery onload, and then onclick event.






should be (I think trying to figure out what you are trying to do)




but all this will do is find a input and append THAT input it to the bottom of div under the form


$("div").append('<input type="text">');


Will append a new input to div, but still outside form.


But! none of these will work correctly until you learn 1 and 2.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...