A continuacion se muestra el contenido de un archivo HTML :
Código PHP:
<body>
<p>Styles make the formatting job much easier and more efficient. To give an attractive look
to
web sites, styles are heavily used.
<span>jQuery is a powerful JavaScript library that allows us to add dynamic elements to our
web sites. </span>Not only is it easy to learn, but its easy to implement too.<br/>
<a href="a1.htm"> jQuery Selectors</a> are used for selecting the area of the document where
we want to apply styles </p>
<h2>Using jQuery</h2>
</body>
Para cambiar el contenido de los nodos <p> y <h2> usaremos los métodos "text" y "html"
text(texto)
Para cambiar el contenido del h2 haremos uso del método "text", tenemos el ejemplo a continuación:
Código PHP:
$(document).ready(function() {
$('h2').text('JavaScript Libraries');
});
html(HTML)
Similar al método "text" es el método "html". Este método cambia el contenido HTML del elemento seleccionado, tenemos el ejemplo a continuación:
Código PHP:
$('h2').html('JavaScript Libraries');