GibboK GibboK - 2 months ago 9
Javascript Question

Add some text using jQuery

I'm using jQuery, I have a div with H2 tags

<div id="preload"><h2></h2></div>

I would like to know how to use jQuery to add a text within the
<h2> tags

Final result should be:

<div id="preload"><h2>Some text here</h2></div>

I need to add the text without replacing the tags
in the jQuery script.

Any ideas? Many thanks!


Try something like this :

$("div#preload h2").html("Some Text Here")

See the above code in action for your sample HTML here