javascript - Add new input and use this without modify HTML -
i have only:
<div> <textarea id="names"></textarea> </div>
i can't modify html. can use jquery. possible make like:
<input type="checkbox" id="yes"> <div style="display:none"> <textarea id="names"></textarea> </div> $("#yes").click(function(){ $("#names").parent().show(); })
default if page loaded , ready should only:
<input type="checkbox" id="yes">
if checked show me div textarea.
is possible make without modify html? if yes, how?
fiddle: http://jsfiddle.net/2zmqz/
var checkbox = $('<input type="checkbox">'); var parent = $('#names').parent().hide().before(checkbox); checkbox.click(function() { parent.toggle(); });
Comments
Post a Comment