【问题标题】:How can we use $(this) and option selected我们如何使用 $(this) 和选择的选项
【发布时间】:2009-12-04 09:50:03
【问题描述】:

$('#selectList :selected').text() 是已知语法

我必须从 $(this) 而不是 $('#selected') 获取相同的值

类似的东西

$(this :selected').text()?

【问题讨论】:

    标签: jquery dom jquery-selectors


    【解决方案1】:

    $() 可以接受两个参数:

    $(selector, context)
    

    所以可以使用

    $(':selected', this).text();
    

    【讨论】:

      【解决方案2】:

      你可以使用任何一个

      $(':selected', this).text();
      

      $(this).find(':selected').text();
      

      【讨论】:

        【解决方案3】:

        或者你也可以这样做:

        $(this).find(":selected").text();

        【讨论】:

          猜你喜欢
          • 2012-08-18
          • 2018-01-06
          • 2017-07-19
          • 2012-04-18
          • 2019-12-30
          • 2011-06-17
          • 2020-03-03
          • 1970-01-01
          • 2011-11-08
          相关资源
          最近更新 更多