Revision: 43315
Updated Code
at March 21, 2011 23:36 by coprolit
Updated Code
/*
Example of inline event handlers:
<input type="text" name="date" onchange="validateDate()" />
This is bad.
The purpose of markup is to describe a document's structure, not its programmatic behavior. And what if we need to set handlers for several events on a single element?
*/
// The unobtrusive solution:
<input type="text" name="date" id="date" />
/*
A script that runs when page is loaded into the browser, looks for relevant element(s) and set them up accordingly: (using jquery)
*/
var message = "mouse entered or left.";
// passing the variable in by value through eventData:
$('#date').bind('mouseenter mouseleave', {msg: message}, function(event) {
alert(event.data.msg);
});
Revision: 43314
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 21, 2011 23:30 by coprolit
Initial Code
// The unobtrusive solution:
<input type="text" name="date" id="date" />
/*
A script that runs when page is loaded into the browser, looks for relevant element(s) and set them up accordingly: (using jquery)
*/
var message = "mouse entered or left.";
// passing the variable in by value through eventData:
$('#date').bind('mouseenter mouseleave', {msg: message}, function(event) {
alert(event.data.msg);
});
Initial URL
http://api.jquery.com/bind
Initial Description
Initial Title
unobtrusive multiple event handlers on single element using jQuery
Initial Tags
javascript, event, jquery
Initial Language
JavaScript