Select elements with an attribute with cheerio

你离开我真会死。 提交于 2019-12-05 07:28:02

Ok I found it in the cheerio documentation, here is how you do it:

$('[name=mode]')

cheerio docs: Selectors

For some reason, the accepted answer didn't work for me (using cheerio ^1.0.0-rc.2 here).

But for the following markup:

<input value="123" name="data[text_amount]">

this did work:

$('input[name="data[text_amount]"]'));

The double quote did the magic. Got that from cheerio's help docs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!