Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Set Text Value to h1 Tag in HTML

Jun 13, 2013
Introduction

Here I will explain how to set text value to h1 tag using jQuery in html.

Description:


Change or Set text value to h1 tag

To change or set h1 tag value we need use append() property for that need to write the code like as shown below


$('h1').append('welcome to aspdotnet-suresh.com');

Above code will append text to all h1 tags if you want to set for only one h1 tag define id for one h1 tag and append text for it like as shown below

HTML

<h1 id="testid">
Best Site for Asp.net, jQuery etc.
</h1>

Script

$('#testid').append('welcome to aspdotnet-suresh.com');

For Example check this post


<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
</head>
<body>
<div id="dvExample">
<h1 id="testid"></h1>
<h1></h1>
</div>
<input type="button" id="btnclick" value="Update All h1 tags" />
<input type="button" id="btnchange" value="Update h1 Id Basis" />
<script type="text/javascript">
$(function() {
$("#btnclick").click(function() {
$('h1').append('welcome to aspdotnet-suresh.com');
})
$("#btnchange").click(function() {
$('#testid').append('welcome to aspdotnet-suresh.com');
})
});
</script>
</body>
</html>


If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

4 comments :

Irtekaz Ahmed Khan said...

Thanks

Venkatesh Ekkaluri said...

HELLO SURESH GARU,
HOW TO CHANGE THE LANGUAGE OF TOTAL WEBPAGE A RUNTIME. CAN U DO THIS FOR ME

Yogananda said...

Post MVC Arch.,LINQ it may helpful 4 the visitors.

Unknown said...

hello sir this is working but after page load h1 text will be gone

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.