Ultimate JavaScript Stuff JQuery
You Are Here: Home » Blog » Ultimate JavaScript Stuff JQuery
Tuesday, 8th July 2008
So what is it? It's a framework. It makes writing JavaScript more structured, less buggy and much cleaner. Once you get the hang of it, you can write something in one line that you used to do on twenty lines.
It's available via the official JQuery website and if you're doing a lot of JavaScript development it will change your life!
I'm currently working on a project that utilises JQuery a lot and it also helps you to follow the Fenton JavaScript ethos, which is great news.
Here's an example... we want to add an event to this anchor tag...
<a href="a_real_page.html" id="alert">Alert</a>
So in old school terms we do this:
document.getElementById("alert").onclick = function() {
alert('Hello World!');
return false;
}
And in the new skool we do this:
$("#alert").click(function() { alert("Hello World!"); return false; });
It looks a bit odd at first, but when you start doing complicated stuff, you suddenly realise how much time and effort you can save!