Thursday, January 08, 2009

Javascript Cheat Sheet

Cause I don't write js often enough to remember its syntax

Add js file to a page

var s=document.createElement('script');
s.setAttribute('src','http://foo.com/bar.js');
document.getElementsByTagName('head')[0].appendChild(s);

Add jQuery to a page

http://www.learningjquery.com/2008/06/updated-jquery-bookmarklet

Append js to a node in DOM w/ jQuery

$("#tab4").append("<script> alert("hello!") </script> ");

No comments: