Skip to content

Instantly share code, notes, and snippets.

@hvent90
Created October 13, 2014 02:04
Show Gist options
  • Save hvent90/cd069f51f52ec52d015f to your computer and use it in GitHub Desktop.
Save hvent90/cd069f51f52ec52d015f to your computer and use it in GitHub Desktop.
click events and anonymous functions
<!--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