HTML and CSS Reference
In-Depth Information
Listing 6-34. Event Handlers That Load the Appropriate Function Upon User Click
<a href="#" onclick="javascript:normal();" >
<img src="images/normal.png" alt="Normal font" title="Normal" />
</a>
<a href="#" onclick="javascript:larger();" >
<img src="images/larger.png" alt="Larger font" title="Larger" />
</a>
<a href="#" onclick="javascript:huge();" >
<img src="images/huge.png" alt="Huge font" title="Huge" />
</a>
Which function will run depends on which image link the user clicks.
Determining JavaScript Support
JavaScript support can be easily determined by a script with an alternate content such as in Listing 6-35.
Listing 6-35. JavaScript with Alternate Content
<script type="text/javascript">
document.write("If this text is displayed, your browser supports scripting, and
JavaScript is enabled!")
</script>
<noscript>JavaScript is NOT enabled!</noscript>
Browsers that do not support JavaScript will show the content of the noscript element.
The Most Common jQuery Functions
jQuery offers a variety of selectors to manipulate markup elements. The most common selectors are summarized in
Listing 6-36.
Listing 6-36. Common jQuery Selectors
// Select element by identifier
$("#ElementID").something();
// Select element by CSS class
$(".ClassName").something();
// Select elements that have an identifier with a string
$("[id*='value']").something();
// Select elements that have an identifier that begins with a string
$("[id^='value']").something();
// Select elements that have an identifier ending with a string
$("[id$='value']").something();
// Select elements of a particular type
$("div").something();
 
Search WWH ::




Custom Search