728x90
SMALL
#jQuery
:empty
: Empty is a selector that selects empty elements with no content.
grammar
$( ':empty' )
for example
$( 'div:empty' )
Select the div element that has no content.
example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery</title>
<style>
table {
width: 100%;
}
td {
border: 1px solid #bcbcbc;
padding: 20px;
text-align: center;
}
</style>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$( document ).ready( function() {
$( 'td:empty' ).append( 'N/A' );
} );
</script>
</head>
<body>
<h1>jQuery Selector - :empty</h1>
<table>
<tr>
<td>Lorem</td>
<td></td>
<td>Ipsum</td>
</tr>
<tr>
<td></td>
<td>Dolor</td>
<td></td>
</tr>
</table>
</body>
</html>
Here is an example of adding an N / A string to a cell that has no table contents.
728x90
LIST