Created
August 16, 2013 00:26
-
-
Save ravidaram/6246200 to your computer and use it in GitHub Desktop.
delegate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>delegate demo</title> | |
<style> | |
td { | |
background: yellow; | |
font-weight: bold; | |
cursor: pointer; | |
padding: 5px; | |
} | |
tr{ | |
background: red; | |
font-weight: bold; | |
cursor: pointer; | |
padding: 5px; | |
} | |
} | |
p.over { | |
background: #ccc; | |
} | |
span { | |
color: red; | |
} | |
</style> | |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
</head> | |
<body> | |
<table> | |
<tr> | |
<td> click me to add row</tr> | |
</tr> | |
</table> | |
<span></span> | |
<script> | |
$( "table" ).delegate( "tr", "click", function() { | |
$( this ).after( "<tr> next row </tr>" ); | |
$( "tr" ).delegate( "td", "click", function() { | |
$( this ).after( "<td> next row </td>" ); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment