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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -