Web Development with jQuery®

(Elliott) #1

(^128) ❘ CHAPTER 4 MANIPULATING CONTENT AND ATTRIBUTES







The following style sheet is applied to the preceding markup document:
body {
font: 12px "Lucida Grande", Arial, sans-serif;
color: rgb(50, 50, 50);
margin: 0 ;
padding: 15px;
}
table.johnLennonAlbums {
table-layout: fixed;
width: 500px;
border: 1px solid black;
border-collapse: collapse;
}
table.johnLennonAlbums th,
table.johnLennonAlbums td {
padding: 3px;
border: 1px solid black;
}
table.johnLennonAlbums th {
text-align: left;
background: lightgreen;
}
table.johnLennonAlbums tbody tr:hover {
background: lightblue;
}
The following script demonstrates both the empty() and the remove() methods:
$(document).ready(
function()
{
$('button#documentEmpty').click(
function(event)
{
event.preventDefault();
$('td').empty();
}
);
$('button#documentRemove').click(
function(event)
{
event.preventDefault();
[http://www.it-ebooks.info](http://www.it-ebooks.info)
Free download pdf