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
$("a.register").on("click", function(e){ | |
$("#signup").fadeToggle(750, "linear"); | |
}); |
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
$("#content").load("somefile.html", function(response, status, xhr) { | |
// error handling | |
if(status == "error") { | |
$("#content").html("An error occured: " + xhr.status + " " + xhr.statusText); | |
} | |
}); |
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
$('input').keydown(function(e) { | |
// variable e contains keystroke data | |
// only accessible with .keydown() | |
if(e.which == 11) { | |
e.preventDefault(); | |
} | |
}); | |
$('input').keyup(function(event) { | |
// run other event codes here |
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
var maxheight = 0; | |
$("div.col").each(function(){ | |
if($(this).height() > maxheight) { maxheight = $(this).height(); } | |
}); | |
$("div.col").height(maxheight); | |
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
var sometext = "here is more HTML"; | |
$("p#text1").append(sometext); // added after | |
$("p#text1").prepend(sometext); // added before |
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
var alink = $("a#user").attr("href"); // obtain href attribute value | |
$("a#user").attr("href", "http://www.google.com/"); // set the href attribute to a new value | |
$("a#user").attr({ | |
alt: "Google", | |
href: "http://www.google.com/" | |
}); // set more than one attribute to new values |
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
$("p").click(function () { | |
var htmlstring = $(this).html(); // obtain html string from paragraph | |
$(this).text(htmlstring); // overwrite paragraph text with new string value | |
}); | |
var value1 = $('input#username').val(); // textfield input value | |
var value2 = $('input:checkbox:checked').val(); // get the value from a checked checkbox | |
var value3 = $('input:radio[name=bar]:checked').val(); // get the value from a set of radio buttons |
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
$("div#home").prev("div"); // find the div previous in relation to the current div | |
$("div#home").next("ul"); // find the next ul element after the current div | |
$("div#home").parent(); // returns the parent container element of the current div | |
$("div#home").children("p"); // returns only the paragraphs found inside the current div |
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
@mixin disable-text-selection() { | |
-webkit-touch-callout: none; | |
-webkit-user-select: none; | |
-khtml-user-select: none; | |
-moz-user-select: none; | |
-ms-user-select: none; | |
user-select: none; | |
} |
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
var height = $(window).height() - 25; | |
$('#sidebar').height(height - 170); | |
window.onresize = function(event) { | |
var height = $(window).height() - 25; | |
$('#sidebar').height(height - 170); | |
} |