在Mozilla Firefox中设置下拉列表的空值不起作用 [英] Setting empty value of a dropdown in Mozilla firefox not working
本文介绍了在Mozilla Firefox中设置下拉列表的空值不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将下拉列表的默认值设置为空;即没有选择任何价值。
$ dropdown.prop(" selectedIndex",-1);
它适用于IE和Chrome,但在Firefox中不起作用。在Firefox中,它总是将下拉列表的第一个值设置为默认值。
我使用的是Mozilla版本23.0.1。
I am trying to set the default value of a drop down as empty; ie not selecting any value.
$dropdown.prop("selectedIndex", -1);
It works in IE and chrome, but doesn't work in Firefox. In Firefox, it always set the first value of the drop down as default value.
I am using Mozilla version 23.0.1.
推荐答案
dropdown.prop(" selectedIndex",-1);
它适用于IE和Chrome,但不起作用在Firefox中。在Firefox中,它总是将下拉列表的第一个值设置为默认值。
我使用的是Mozilla版本23.0.1。
dropdown.prop("selectedIndex", -1);
It works in IE and chrome, but doesn't work in Firefox. In Firefox, it always set the first value of the drop down as default value.
I am using Mozilla version 23.0.1.
尝试以下JQuery代码:
Try the following JQuery codes:
//with single quotes
dropdown.prop(' selectedIndex' , - 1);
// 或attr
dropdown.prop('selectedIndex', -1); //or with attr
这篇关于在Mozilla Firefox中设置下拉列表的空值不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文