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 Replies to “Simple Example of jQuery in Action”

    1. 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!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s