微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何检查值是否已存在于 Java Script 的 ListBox 中

如何解决如何检查值是否已存在于 Java Script 的 ListBox 中

后面代码的答案如下:

if (!listBoxInstance.Items.Contains("some text")) // case sensitive is not important
            listBoxInstance.Items.Add("some text");
if (!listBoxInstance.Items.Contains("some text".ToLower())) // case sensitive is important  
            listBoxInstance.Items.Add("some text".ToLower());

在这将如何在 Java Script 中完成? TIA。

解决方法

这个 listBox.items 是一个对象吗? 如果是这样:

if (!listBoxInstance.Items["some text"]) // case sensitive is not important
            listBoxInstance.Items["some text"] = // the value of the property you want to assign;
if (!listBoxInstance.Items[`${"some text".toLowerCase()}`]) // case sensitive is important  
            listBoxInstance.Items[`${"some text".toLowerCase()}`);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。