Created
April 5, 2013 01:12
-
-
Save sauron/5315848 to your computer and use it in GitHub Desktop.
Comparaciones entre live() y on()
This file contains hidden or 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> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> | |
<script> | |
function addClick(){ | |
$("span.clickeable").live("click", function(){ | |
alert("clicked"); | |
}) | |
}; | |
function addSpan(){ | |
$("body").append('<br /><span class="clickeable">Clickeable</span>') | |
}; | |
$(document).ready(function() { | |
addClick(); | |
}); | |
</script> | |
</head> | |
<body> | |
<a href="javascript:addSpan()">Agregar otro clickeable</a> | |
<br /> | |
<span class="clickeable">Clickeable</span> | |
</body> | |
</html> |
This file contains hidden or 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> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
<script> | |
function addClick(){ | |
$("span.clickeable").on("click", function(){ | |
alert("clicked"); | |
}) | |
}; | |
function addSpan(){ | |
$("body").append('<br /><span class="clickeable">Clickeable</span>') | |
}; | |
$(document).ready(function() { | |
addClick(); | |
}); | |
</script> | |
</head> | |
<body> | |
<a href="javascript:addSpan()">Agregar otro clickeable</a> | |
<br /> | |
<span class="clickeable">Clickeable</span> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment