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
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel='stylesheet' href='styles.css'/> | |
</head> | |
<body> | |
<div class="flex-container"> | |
<div class="flex-item">Item 1</div> | |
<div class="flex-item">Item 2</div> | |
<div class="flex-item">Item 3</div> |
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
Changing Content of HTML through jQuery | |
<html> | |
<head> | |
<script type="text/javascript" src="jquery.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$("button").click(function(){ | |
$("p").html("Change the content with jQuery"); | |
}); |
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
Check if and which key was pressed | |
$(function() { | |
$(document).keypress(function(e){ | |
switch(e.which){ | |
// "ENTER" | |
case 13: | |
alert('enter pressed'); | |
break; | |
// "s" |
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
$('#foo').bind('click', function() { | |
alert('User clicked on "foo."'); | |
}); |
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
$('button.someClass').live('click', someFunction); | |
//Note that in jQuery 1.4.2, the delegate and undelegate options have been | |
//introduced to replace live as they offer better support for context | |
//For example, in terms of a table where before you would use.. | |
// .live() | |
$("table").each(function(){ | |
$("td", this).live("hover", function(){ | |
$(this).toggleClass("hover"); | |
}); |
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
var elements = $('#someid input[type=sometype][value=somevalue]').get(); | |
//This precision-based approached can be useful when you use lots of similar input elements which have different types | |
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
if ($('#div').html()) { } |
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
$('#div').replaceWith('sample'); |
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
//jQuery 1.4.* includes support for the has method. This method will find | |
//if a an element contains a certain other element class or whatever it is | |
//you are looking for and do anything you want to them. | |
$("input").has(".email").addClass("email_icon"); |
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
$('#div').append('text'); |
NewerOlder