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

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -