How to change only text inside a div which has other divs

html, jquery

Solution

If you dont want it in a single line.

var tmp=$("#header>div").html();
$("#header").text("its thursday").append('<div>'+tmp+'</div>');

jsfiddle

Problem

I have html below. What I want to do depends on some conditions. I want to keep changing the text which is `Sometitle`. ``` <div id="header"> Sometitle <div> <div> aa </div> <div> bb </div> </div> </div> ``` I tried using Jquery below but it removes the other divs also. ``` $("#header").text("Its a thrusday today !"); ``` How do I get this done? I cannot modify this HTML in any case. I just have to use jquery and get this thing done. Here is a jsfiddle I created : http://jsfiddle.net/qYUBp/

Original source

Related problems