C# jQuery text()与<;选择>;
我有一个下拉列表,如下所示:C# jQuery text()与<;选择>;,c#,jquery,asp.net,C#,Jquery,Asp.net,我有一个下拉列表,如下所示: <select id="example" name="example" runat="server"> 单击列表中的项目,我就有了jQuery函数: $inputs = this.inputs, $checked = $inputs.filter(':checked'), $checked.each(function (index) { alert($(this).text()); }); 但是
<select id="example" name="example" runat="server">
单击列表中的项目,我就有了jQuery函数:
$inputs = this.inputs,
$checked = $inputs.filter(':checked'),
$checked.each(function (index) {
alert($(this).text());
});
但是$(this).text()
总是作为空字符串返回
我做错什么了吗?请帮忙
提前感谢。您正在查找
:选中的属性,而不是:选中的您正在查找:选中的属性,而不是:选中的尝试以下操作:
$inputs = this.inputs,
$checked = $inputs.filter.is(':checked'),
$checked.each(function (index) {
alert($(this).text());
});
试试这个:
$inputs = this.inputs,
$checked = $inputs.filter.is(':checked'),
$checked.each(function (index) {
alert($(this).text());
});
试试这个
$inputs = this.inputs;
$checked = $inputs.val();
$checked.each(function (index) {
alert($(this).text());
});
试试这个
$inputs = this.inputs;
$checked = $inputs.val();
$checked.each(function (index) {
alert($(this).text());
});
我使用以下公式得到了值:
$inputs = this.inputs,
$checked = $inputs.filter(':checked'),
$checked.each(function () {
alert(($(this)[$(this).index()].title));
我使用以下公式得到了值:
$inputs = this.inputs,
$checked = $inputs.filter(':checked'),
$checked.each(function () {
alert(($(this)[$(this).index()].title));
在下拉列表中,我们需要在选择选项后填充要选择的n'of选项。我们可以使用下面的查询获取所选文本
var exampleValue=$(“#示例选项:选定”).text() 在下拉列表中,我们需要在选择选项后填充要选择的n'of选项。我们可以使用下面的查询获取所选文本
var exampleValue=$(“#示例选项:选定”).text() 我已将选择器更改为$checked=$inputs.filter(':selected'),现在我没有得到任何选中/选中的项目我已将选择器更改为$checked=$inputs.filter(':selected'),现在我没有得到任何选中/选中的项目