Any time you see something like

$("a").addClass("test");

You can assume this is JavaScript. In particular, this is JS that makes use of the jQuery library. JavaScript can only appear in certain places - either in an included .js library (via <script type="text/javascript" src="someLibrary.js"></script>), or within <script> tags.

Where jQuery is concerned, the $() method is not available until after the jQuery library has been included. So make sure you include the library BEFORE doing anything that makes use of jQuery.

In addition though, you often don't want the jQuery code executed until the page is done loading. In this case, if the addClass method is called before the HTML is rendered, then nothing will happen because the $("a") would return nothing. In this case you want to make sure your command is put inside the .ready() method. For example:

<script type="text/javascript">
  $(document).ready( function () {
    $("a").addClass("test");
  });
</script>

I haven't looked at the tutorial in years, but hopefully this is enough to help figure out what you need.

I might suggest though to maybe nail down the HTML know-how, and read up on basic JS. Both will help make this all make sense. As is you might be taking on too much all at once and overwhelming or confusing yourself - but that's how I learn too, so whichever works best for you.

BTW, Dreamweaver isn't a bad tool, but if you are working at this level, put Dreamweaver into Code View, and don't use the Design View at all. It might take a bit more to learn to start with, but you need to know how to do everything by hand eventually (i.e. no graphical tool to write code)... may as well start now. My thoughts though.

Shawn

keithcoo wrote:
I went through part of the tutorial, and when i got to the section
"adding and removing a css class" i got stuck. the question i have is
this: do we add the    $("a").addClass("test");  part to the html file
we created in the tutorial section "The basics"? if so, do we need to
delete some of the stuff we stuck in that file we created before we
add the     $("a").addClass("test");   ?  im new to dreamweaver and
html and all this kinda stuff, so talk to me like im a beginner. if
the creaters of this tutorial are reading this, it would be helpful if
you gave an example of how the whole file would look for each section
of the tutorial, so that there is no confusion for guys like me.
thanks!

keith

Reply via email to