Thursday, December 8, 2011

Changing Text Content with jQuery

Two elements with their HTML code swapped.Sometimes you don’t want the actual HTML code in an element; you want
only the text. To do so, replace the html() function with the text() function.
In the preceding example, you swapped the HTML code. If you want to
swap only the text and not the HTML code, use this code:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”

“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

<html>

<head>

<title>My Test Page</title>

<script type=”text/javascript” src=”jquery-1.6.4.min.js”></script><script type=”text/javascript”>

$(document).ready(function(){

var strongContent = $(‘strong’).text();

var pContent = $(‘p’).text();

$(‘strong’).text(pContent);

$(‘p’).text(strongContent);

});

</script>

</head>

<body>

<strong>This is the text in the <em>STRONG</em> element.</strong>

<p>This is the text in the <em>P</em> element.</p>

</body>

</html>

Free create back link
Meta tag generator 4 seo
If else statement
Increase traffic your blogs
Free Web Promotion



0 comments:

Blogs 4 seo/blogspot seo|blogs best 300x250 banners Copyright © 2011 -- Template created by O Pregador -- Powered by Blogger

Web Statistics