views:

26

answers:

2

i know there is probably a better way of doing this, i have tried many ways. i would normally do the .hide() or .show() but the css display switch has been working better on FF, not on IE. anyway here is my code

$(".VariationSelect option[value='21']").click(function () {
    $("#21").css("display", "block");
});
$(".VariationSelect option[value!='21']").click(function () {
    $("#21").css("display", "none");
});

ive tried case switch and if and else but no worky

please let me know asap

oops heres the html

<div class="Value">
    <select name="variation[1]" class="VariationSelect" style="width: 180px;">
        <option value="">Choose a Ring Size</option>
        <option value="6">6</option>
    <option value="7">7</option>
    <option value="21">Custom</option>
    </select>
</div>
<div id="21" style="margin-left:20px; float:left; display:none"> 
    <div class="Label" style="margin-top:5px; ">
        Custom Size:&nbsp;&nbsp;
    </div>
</div>
A: 

Is the click function called when you click on the "option" in IE? My guess is click events aren't triggered on option elements in IE. Put a change(..) on the select instead and test the value.

Here is the code:

    $(".VariationSelect").change(function() {
    if ($(this).val() == "21") {
        $("#21").css("display", "block");
    } else {
        $("#21").css("display", "none");
    }
});
Plaudit Design - Web Design
woo hoo worked like a charm c;
Alex
Please accept the answer
Plaudit Design - Web Design
A: 

First off, I wouldn't recommend using IDs and classes that start with a number.

jQuery

$(".VariationSelect").change(function() {
    if ($(this).val() == '21') {
        $("#cont_21").show();
    } else {
        $("#cont_21").hide();
    }
});

HTML

<div id="cont_21" style="margin-left:20px; float:left; display:none"> 
    <div class="Label" style="margin-top:5px; ">
        Custom Size:&nbsp;&nbsp;
    </div>
</div>

JSFiddle Demo here.

Hope this helps !

FreekOne
Sorry for the near-duplicate answer. When I started writing it, there was no code posted :)
FreekOne
yeah the hide show would work too thanks!
Alex
@FreekOne Im always amazed how quick people respond to questions. So many times by the time I am done writing a response someone else has already answered it. :-)
Plaudit Design - Web Design
@Plaudit Indeed, that happens a lot :)
FreekOne