Friday, October 2, 2009

[jQuery] Re: something missing from my code?

When you write:
$('a projTwo').click(function() {
You want to identify the correct a by its class name (projTwo).
So you would want to write it as:
$('a.projTwo').click(function() {
Notice the difference?

On 2 Okt, 15:00, Glen_H <glen.f.he...@gmail.com> wrote:
> Hey guys, Im new to Javascript and JQuery, I am trying to have a
> "featured" area on the front page to my site, basically there is a
> right div area which holds the picture, on the left there is a menu
> with 4 buttons. here is the html:
>
> <div id="projectmenu">
>
>      <ul id="projMenu">
>
>         <li><a class="projOne" title="Project1"></a></li>
>         <li><a class="projTwo" title="Project2"></a></li>
>         <li><a class="projThree" title="Project3"></a></li>
>         <li><a class="projFour" title="Project4"></a></li>
>     </ul>
>       </div>
>         <div class="project" id="project1"></div>
>         <div class="project" id="project2"></div>
>         <div class="project" id="project3"></div>
>         <div class="project" id="project4"></div>
>
>     </div>
>
> Here is the way im setting up the JQuery to try and make the active
> div change when I choose a button:
>
> $(function() {
>                    $('a projTwo').click(function() {
>                                         $('#project1').css('display','none');
>                                         $('#project2').css
> ('display','');
>
>                                                                                  });
>                    });
>
> does anyone see where I am going wrong? when I get into the CSS
> portion will it have to go all the way back like how css is written?
> meaning in order to identify it, would it have to be #container
> #project1 or will just #project1 work?
>
> thank you in advance

No comments: