jQuery - 选项上的选定属性不显示在FireBug中 [英] jQuery - selected attribute on options doesn't show in FireBug

查看:117
本文介绍了jQuery - 选项上的选定属性不显示在FireBug中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么?



当我在select字段中选择一个选项时, selected =selected属性仍然停留在以前的选择。但从外观上看,你可以看到新的选项是活动的

解决方案

从下拉列表中选择一个选项不会修改在DOM中选择属性。但是,如果使用 $('#selectId')。val()查询当前值,它将返回当前选定选项的值。 b

Why?

when I select a option in a select field, the selected="selected" attribute still stays on the previous option. But visually you can see that the new option is active

解决方案

Selecting an option from the dropdown doesn't modify the selected attribute in the DOM. But if you query the current value using $('#selectId').val() it would return the value of the currently selected option.

这篇关于jQuery - 选项上的选定属性不显示在FireBug中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆