swoonvin 0 Posted July 19, 2015 Report Share Posted July 19, 2015 <!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?? Quote Link to post Share on other sites
dsonesuk 913 Posted July 19, 2015 Report Share Posted July 19, 2015 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. This $("div").append("$("input"); should be (I think trying to figure out what you are trying to do) $("div").append("input"); 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. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.