Have a problem… I am appending a form element to a page with jQuery. However i cannot access the form element with js. I think this is because the dom has loaded and the form element isn’t available in the dom. Is there a work around for this. I know I can append an Iframe with the form inside but would rather not.
Heres an example…
<body>
<div id=wrapper>
</div>
<div onlclick='newInput()'>
Add Detail...
</div>
</body>
And the jQuery…
function newInput(){
var container = "<div id='input-container'><input id='input' type='text' value='insert new data here'></input><div id='submit onclick='submitInput()'>SUBMIT</div>";
$('div#wrapper').append(container);
}
function submitInput(){
var input = document.getElementById('input').value;
....do stuff with ne input here....
}
Why do you have two single quotes shown below ?
I would double check and make sure you’re not getting any errors in the console, just in case the js is throwing an error. Your code works for me http://jsfiddle.net/4xxGJ/