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(); }); 

http://jsfiddle.net/2zmqz/14/


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -