Introduction:
Here I will explain how to set text value to h1 tag using
jQuery
in html.
Description:
In previous articles I explained jQuery show gridview row details in tooltip on mouseover, 8 video player plugin examples, jQuery reload iframe every few seconds, jQuery calculate page load time, jQuery Scrollable gridview with fixed header, jQuery highlight border & background of form controls when
validation fails and many articles relating to JQuery,
JavaScript, asp.net,
code snippets. Now I will explain how to set text value to
h1 tag using jQuery in html.
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. |
|||
|
|||
4 comments :
Thanks
HELLO SURESH GARU,
HOW TO CHANGE THE LANGUAGE OF TOTAL WEBPAGE A RUNTIME. CAN U DO THIS FOR ME
Post MVC Arch.,LINQ it may helpful 4 the visitors.
hello sir this is working but after page load h1 text will be gone
Note: Only a member of this blog may post a comment.