最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - cheerio selector for first nested html element - Stack Overflow

programmeradmin5浏览0评论

This Meteor server side code is trying to get the amount 77 which is in this html string but my selector is returning empty object. How can I get 77 out of this html? Thanks

$('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>

This Meteor server side code is trying to get the amount 77 which is in this html string but my selector is returning empty object. How can I get 77 out of this html? Thanks

$('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>
Share Improve this question edited May 23, 2016 at 19:47 Fred J. asked May 23, 2016 at 19:07 Fred J.Fred J. 6,03913 gold badges60 silver badges112 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 14
$('select[name=paid] option').first().attr('value')

Should work! Your code is too general and won't return anything because there is more than one option.

发布评论

评论列表(0)

  1. 暂无评论