Created
October 13, 2014 02:04
-
-
Save hvent90/cd069f51f52ec52d015f to your computer and use it in GitHub Desktop.
click events and anonymous functions
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
<!--before--> | |
<script> | |
$(document).ready(function(){ | |
$('.text_1').click(function() { | |
$("p").prependTo( $(".text_3")); // The following code CLONES rather than "moves" the text: $("p").clone().prependTo(".text_3"); | |
$('.text_2').click(function() { | |
$("h3").prependTo( $(".text_4")); | |
}); | |
}); | |
}); | |
</script> | |
<!--after--> | |
<script> | |
$(document).ready(function(){ | |
<!-- Start of the first click function --> | |
$('.text_1').click(function() { <!-- Body of the anonymous function starts here --> | |
$("p").prependTo( $(".text_3")); | |
}); <!-- body of the first anonymous function and the click function ends here --> | |
<!-- Start of the second click function --> | |
$('.text_2').click(function() { <!-- Body of the anonymous function starts here --> | |
$("h3").prependTo( $(".text_4")); | |
}); <!-- Body of the second anonymous function and the click function ends here --> | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment