.delegate()
In this chapter you will learn:
.delegate() event
The .delegate()
method binds a handler
independent of whether the DOM element exists.
<html> <!-- j a v a 2 s.co m-->
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script>
$(function(){
$("body").delegate("p","click",function(){
document.writeln('ouch');
}).css("color", "green");
});
</script>
</head>
<body>
<p>Hit Me! ja va2s.com</p>
</body>
</html>
Next chapter...
What you will learn in the next chapter: