1
<script type="text/javascript">
                $(document).ready(function() {
            $('#Catid').change(function(){
                var optvalue = $(this).val(),
                div = $('#' + 'parentid' + optvalue);
                $('div').hide();
                div.show();
            });
        });​ 
              </script>

Im getting a console error but I have no idea why

4

2 に答える 2

5

最後の行に問題があるようです。そこの最後に隠されたキャラクターがいます。それを削除してもう一度書いてください、それはそれをソートするはずです!

于 2012-12-28T21:19:12.883 に答える
2

You've asked "What is wrong with the syntax in this", so I figured I should point this one out too.

The problem is with this code here:

div = $('#' + 'parentid' + optvalue);

The div is a global variables and it is consider bad practice.

A better way to rewrite this is to include this as part of the initial var.

var optvalue = $(this).val(),
    div      = $('#' + 'parentid' + optvalue);
于 2012-12-28T21:30:41.517 に答える