Skip to content

Instantly share code, notes, and snippets.

@donoage
Last active May 23, 2016 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donoage/e44f314f24314aac6c12e780d89cf4cf to your computer and use it in GitHub Desktop.
Save donoage/e44f314f24314aac6c12e780d89cf4cf to your computer and use it in GitHub Desktop.
$(document).ready(function() {
//.submit() is only for <form> element.
// use .click() for .navLinks
$(".navLinks").click(function(event) {
event.preventDefault();
});
$(".post").click(function(event) {
event.preventDefault();
});
$(".readmore").click(function(event) {
event.preventDefault();
console.log("prevented!")
});
$(".readmore").click(function() {
$(".readmore").hide();
$("#show-this-on-click").slideDown("slow");
$(".readmore").hide();
$(".readless").show();
console.log("readmoreallowed")
});
$(".readless").click(function() {
//check out this line where we pass in another 'anonoymous function' as a parameter for slideUp()
// this makes whatever's inside of anonoymous function gets fired AFTER slideUp() animation is done.
$("#show-this-on-click").slideUp("slow", function() {
$(".readmore").show();
$(".readless").hide();
});
console.log("readlessallowed")
});
$(".sideBarLinks").click(function(event) {
event.preventDefault();
});
//No need for a seperate click function for event.preventDefault().
//See below.
//
//
// $(".learnmore").click(function(event) {
// event.preventDefault();
// });
// $(".learnless").click(function(event) {
// event.preventDefault();
// });
$(".learnmore").click(function(event) {
event.preventDefault();
$("#learnmoretext").slideDown("slow");
$(".learnmore").hide();
$(".learnless").show();
});
$(".learnless").click(function(event) {
event.preventDefault();
$(".learnless").hide();
$(".learnmore").show();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment