Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# jQuery text()与<;选择>;_C#_Jquery_Asp.net - Fatal编程技术网

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'),现在我没有得到任何选中/选中的项目