PDA

View Full Version : what does it all mean?????


tony09uk
02-28-2011, 10:00 PM
When I first started to learn Dreamweaver I didn't realize coding was absolutely necessary. I when I set out to learn HTML, then CSS I decided that I wouldn't just copy and paste code, I wanted to learn to do it myself and get a complete understanding of it all before I moved onto any other code. At that point I didn't realise that I would need other code to get the page which I wanted.

I have broke my "vow" I have copied and pasted some code, from what the site says it is basic code, but I haven't a clue what im looking at. I am now concerned something may happen with my page and I won't have a clue how to make the necessary adjustments. Could someone please give a basic breakdown of what the below means or the direction to a site where I can get a quick basic overview of jquery. (i don't intend on learning any more that I have to anytime soon though)

$(document).ready(function() {

//Default Action
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content

//On Click Event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active content
return false;
});

});

edbr
03-01-2011, 12:25 AM
http://docs.jquery.com/How_jQuery_Works

gentleone
03-01-2011, 08:33 AM
The dollar sign is just an alias for 'jQuery', so you could also write jQuery(document).ready(function(). With document ready you say first load the DOM (Document Object Model), in other words first load all the HTML & CSS and then the jQuery function.

Furthermore I think I can't be more clear then the comments the author added after each line to explain what each line actually does.

tony09uk
03-02-2011, 12:14 AM
I thought I'd learnt!! I did the same with jquery as I did with css and HTML, soon as it was slightly different to anything i'd seen before I freaked, but now you've pointed out there comment markers, it seems so much clearer. and the tutorial will be of great help, many thanks both of you :D