Simple Example of jQuery in Action

What do you do when you’re working from a Dreamweaver-templated page and need to make a simple tweak? Enter jQuery!

Problem: The page I’m editing was set up as a page with a sidebar, but the content given doesn’t need a sidebar.
Solution: With the help of jQuery, I eliminated the sidebar and widened the main content column. Magic!

jQuery code:
$(document).ready(function(){ //when document has loaded...
$('div#sidebar').remove(); //remove sidebar
$('div#main').css('width', '950px'); //increase width of main div
}); //this bit of jQuery expands the main content area without having to recreate the page in a sidebar-free template

I’m only super happy about this because I am very new to jQuery and I wrote this from what little I knew of the language already. An accomplishment and step in the right direction for a newbie.

2 responses to “Simple Example of jQuery in Action”

    • That’s actually a great idea and probably more practical! I think I’m on a jQuery kick right now. But I most definitely prefer a CSS solution first, when possible, or within my ability. Thanks!

      Like

Leave a comment

Create a website or blog at WordPress.com