Java Reference
In-Depth Information
maintain. So when it came to events, John Resig, the creator of jQuery, decided to create his own
Event object and base it on the standard DOM Event object. This means that you do not have to
worry about supporting multiple event models; it's already done for you. All you have to do is write
standard code inside your event handlers.
To demonstrate, you can write something like the following code, and it'll work in every browser:
function clickHandler(e) {
e.preventDefault();
alert(e.target.tagName + " clicked was clicked.");
}
$(".class-two").on("click", clickHandler);
Note For a complete list of supported events, see jQuery's website at
http://docs.jquery.com/Events .
rewriting the tab strip with jQuery
You have learned how to retrieve elements in the DOM, change an element's style by adding and
removing classes, add and remove elements from the page, and use events with jQuery.
Now you'll put this newfound knowledge to work by refactoring the toolbar from Chapter 10.
revisiting the tab Strip with jQuery
trY it out
Open your text editor and type the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chapter 16: Example 1</title>
<style>
.tabStrip {
background-color: #E4E2D5;
padding: 3px;
height: 22px;
}
.tabStrip div {
float: left;
font: 14px arial;
cursor: pointer;
}
.tabStrip-tab {
padding: 3px;
 
Search WWH ::




Custom Search