Skip to content

Instantly share code, notes, and snippets.

View devi's full-sized avatar
⛰️
Off-Grid

Devi Mandiri devi

⛰️
Off-Grid
View GitHub Profile
@devi
devi / gist:824742
Created February 13, 2011 15:02
addCss, addJs
$.fn.addCss = function(css){
var style = document.createElement('link');
style.rel = 'stylesheet';
style.type = "text/css";
style.href = css;
document.getElementById($(this).attr('id')).appendChild(style);
};
$.fn.addJs = function(js){
var script = document.createElement("script");
@devi
devi / gist:800524
Created January 28, 2011 16:43
hashbang
// jquery hashbang(#!)
function hasbang(){
$('a').each(function(){
var o = $(this), url = o.attr('href'), p = url.match('^https?://');
var h1 = location.hostname, h2 = h1.replace(/^www\./i,'');
if (url == '#') {
o.attr('href','javascript:void(0);');
return;
}