开发者

jQuery: Selecting custom html tags (with specific values)

开发者 https://www.devze.com 2023-03-18 11:20 出处:网络
I have an html page which has elements such as the following: <input data-required-by=\"books magazines stationery\">

I have an html page which has elements such as the following:

<input data-required-by="books magazines stationery">

What I'd like to do is select all elements in jQuery that have "books" in the 'data-required-by' field. I was hoping something such as the following would work:

$("[data-required-by]~='books'")

but it brings back "Syntax error, unrecognized expression: ='books'"

Admittedly my jQuery isn't particularly advanced, so it's possible I've missed something simple. Any suggestions appreci开发者_如何学Pythonated


$("input[data-required-by~=books]")


$('[data-required-by^=books]')
0

精彩评论

暂无评论...
验证码 换一张
取 消