jquery - How to pass updated input value? -
i have input field value. trying capture new text added input , pass value input. each time pass however, old value passed. realise simple error making, can't seem working although have tried many times different approaches. trying using zurb joyride plugin. so, first input within step on walkthrough , passed input on page itself.
any appreciated.
here stripped down code:
html
<input type="text" id="egtext" value="stuff" /> <a href="#" onclick="addtext()" class="btn">button</a> <input type="text" id="searchbox" placeholder="a placeholder" />
js
function addtext() { var text = $("#egtext").val(); $("#searchbox").val(text); }
jsfiddle http://jsfiddle.net/figlen/zyapmc7h/
$('.btn').on('click', function(){ var text = $("#egtext").val(); $("#searchbox").val(text); });
i've included fiddle, it's best practice not use inline functions.
Comments
Post a Comment