开发者

Select all element with a not null id, in jQuery

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜