开发者

Select all element with a not null id, in jQuery

开发者 https://www.devze.com 2023-01-15 21:01 出处:网络
I want to implement .draggable class to all elements in my document, with an existing id using jQuery 1.4.2

I want to implement .draggable class to all elements in my document, with an existing id using jQuery 1.4.2

<div id="blabla">asdsda</div> -> 开发者_开发知识库OK
<div>dsds</div> -> NOT OK

Is this possible ?

i tried : $("*[id!=null]") but i does not work :s


$("*[id]")

should work, and - for the record -

$("*:not([id])")

is the opposite.


$('[id]')

This will grab all elements that have an 'id' attribute.

Or to get all divs with an 'id' attribute you can do:

$('div[id]')

Has Attribute Selector


Use it:

$("div[id]")

See in jsfiddle.

0

精彩评论

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

关注公众号