开发者

jquery script not functioning correctly in IE8 - perfect in FF

Can anyone help me with this jquery script - I am not a programmmer and have been given this script but the writer can't help....

I have a script that functions perfctly in FF but in IE8 something weird happens:

  • what should be case 1 will choose case 2 (or 3 if coming from case 3)
  • what should becase 2 will choose case 3
  • what should becase 3 will choose case 2 (or 3 if coming from case 1)

does this make sense?

anyway this is the script-

<script type="text/javascript" src="js/jquery/jquery-core.js"></script>
<script type="text/javascript">

function hideall() {
    $('#li_9').hide();
    $('#li_56').hide();
}

$(document).ready(function() {
    hideall();

    $("#form_40 input[@name='element_59']").change(function() {
        hideall();

        switch($(this).val()) {
            case '1' :
      开发者_如何学编程          $('#li_9').show();
                break;

            case '2':
                $('#li_9').show();
                $('#li_56').show();
            break;

            case '3' :
                $('#li_56').show();
            break;
        }
    });
});


The only thing that jumped out at me was

input[@name='element_59']

I looked through the jQuery API and didn't see any references to what "@" did before the name. You may want to verify you are using it correctly.

Other than that you can make some improvements in your selectors by chaining your show and hide functions like this:

$('#li_9, #li_56').hide();

$('#li_9, #li_56').show();

The other thing is your example above doesn't close out the 'change' method or the 'ready' event. I'm assuming this is just how it's posted here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜