html - Replace text in div and not in other elements with jquery -
i have issue, here html
<div id="slider" class="hidden"> <input type="button">x</input> </div>
and here jquery:
var el = $('#slider').clone(); el.removeclass("hidden"); el.text("my humble text"); $("#otherdiv").append(el);
so issue when execut jquery, replaced button x .. because seemed text.
my question how add text div, let other elements texts ...?
use .append() instead of .html()
var el = $('#slider').clone(); el.removeclass("hidden"); el.append("my humble text"); $("#otherdiv").append(el);
demo: fiddle
also
- the resulting html contain multiple elements id
slider
, have change id of cloned element <input type="button">x</input>
should<input type="button" value="x">
Comments
Post a Comment