markzzz
markzzz

Reputation: 48045

trouble with .toggle()

I have this CSS:

.linkMenu {
    width: 710px;
    height: 30px;
    color: #CCCCCC;
    font-weight: bold;
    float: left;
    text-align: left;
}

And this HTML:

<div id="linkAnchor0" class="linkMenu">
    text1
</div>

<div id="linkAnchor1" class="linkMenu" style="display:none;">
    text2
</div>

I'd like to know why $("#linkAnchor1").show(); works (it shows the second div) and why $("#linkAnchor1").toggle(); doesn't work (nothing is shown).

Where am I wrong?


EDIT

The whole jQuery code:

function showLinks(param) {
    if(param!="") {
        for(i=0; i<10; i++) {
            if(i<param) {
                $("#linkAnchor"+i).toggle();
            } else {
                $("#linkAnchor"+i).toggle();
                $("#linkAnchor"+i).find(".linkValue").children().val("");
            }
        }
    }
}

Upvotes: 0

Views: 188

Answers (1)

UnstableFractal
UnstableFractal

Reputation: 1422

If i'm getting this right, you're trying to do this:


function showLinks(param) {
  $(".linkMenu").toggle();
  $(".linkMenu:gt("+param+")").find(".linkValue").children().val("");
}

Upvotes: 2

Related Questions