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.
精彩评论