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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
<?php | |
//get the q parameter from URL | |
$q=$_GET["q"]; | |
//find out which feed was selected | |
if($q=="Google") | |
{ | |
$xml=("http://news.google.com/news?ned=us&topic=h&output=rss"); | |
} | |
elseif($q=="MSNBC") |
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(document).ready(function($){ | |
$("h3").each(function(){ | |
if ($(this).text().length > 30) { | |
$(this).text($(this).text().substr(0, 27)); | |
$(this).append('...'); | |
} | |
}); | |
}); | |
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 newDiv = $('<div></div>'); | |
newDiv.attr("id","myNewDiv").appendTo("body"); |
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(function () { | |
jQuery(":contains(FIND)").not(":has(:contains(FIND))").each(function () { | |
var that = $(this), | |
html = that.html(); | |
html = html.replace(/(\(FIND:.*?\))/g, "REPLACE-WITH"); | |
that.html(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 id="overlay"></div>') | |
.css({ | |
position : 'fixed', | |
top : 0, | |
left : 0, | |
right : 0, | |
bottom : 0, | |
opacity : 0.6, | |
background : 'black', | |
display : 'none' |
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 object = | |
{ | |
a:10; | |
b:20; | |
s:'hello' | |
}; | |
$.each(object, function(name, value) |
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 truck = function() { | |
this.turnLeft = function { | |
// turn left | |
return this; | |
} | |
this.turnRight = function { |
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(function () { | |
jQuery('#select_ID').change(function () { | |
var selected = $(this).find(':selected').val(); | |
jQuery(".item_to_hide").hide(); | |
jQuery('#' + selected).show(); | |
}).change(); | |
}); | |
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 version | |
jQuery.inArray("value", arr); // Usage: if( jQuery.inArray("value", arr) != -1 ) { true }; | |
//Javascript version | |
Array.prototype.inArray = function (value) { | |
var i; | |
for (i=0; i < this.length; i++) { | |
if (this[i] === value) { | |
return true; | |
} |
OlderNewer