【问题标题】:cheerio selector for first nested html elementCheerio 选择器用于第一个嵌套的 html 元素
【发布时间】:2016-05-23 19:07:24
【问题描述】:

此 Meteor 服务器端代码试图获取此 html 字符串中的数量 77,但我的选择器返回空对象。我怎样才能从这个 html 中得到 77?谢谢

$('select[name=paid] option').data();
<td class="displayValue">

            <select name="paid" id="paidId"><option value="77.00" selected="selected">77.00</option>


              <option value="Other">Other</option></select>

      </td>
    </tr>

【问题讨论】:

    标签: javascript jquery cheerio


    【解决方案1】:
    $('select[name=paid] option').first().attr('value')
    

    应该工作!您的代码太笼统,不会返回任何内容,因为有多个选项。

    【讨论】:

      猜你喜欢
      • 2014-01-20
      • 2013-12-24
      • 2022-11-30
      • 1970-01-01
      • 1970-01-01
      • 2012-04-09
      • 1970-01-01
      • 2013-03-25
      • 1970-01-01
      相关资源
      最近更新 更多