0

我在这样的模板中有一个 jquery js 代码:

<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery("select").change(function(){
            var str = $('select option:selected').text();
                alert(str);
            });
        });
</script>

并且,由上面的 js 代码处理的选择表单:

class GrupEklemeFormu(forms.Form):
    GORL = (
        (1, ("Global")),
        (2, ("Lokal")),
    )
    g_or_l = forms.ChoiceField(choices=GORL)

当我在页面中选择 Global 或 Local 时,str 变为“GlobalGlobal”或“GlobalLokal”。这是什么原因?我怎样才能摆脱错误。谢谢..

4

0 回答 0