Introduction:
Here
I will explain how to set text value to h1 tag using jQuery in html.
Description:
In
previous articles I explained jQuery Create Read Cookie Get Set Delete Cookies Example,jQuery Get Number of Facebook likes, Shares, Comments Count for Url or Website and
many articles relating to JQuery, JavaScript, asp.net. 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 gohilinfotech.in'); |
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 gohilinfotech.in');
|
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 gohilinfotech.in');
})
$("#btnchange").click(function() {
$('#testid').append('welcome to gohilinfotech.in');
})
});
</script>
</body>
</html>
|
0 comments :
Post a Comment