Select all elements with null id in jQuery

I want to implement a .draggable class for all elements in my document using an existing identifier using jQuery 1.4.2

<div id="blabla">asdsda</div> -> OK <div>dsds</div> -> NOT OK 

Is it possible?

I tried: $("*[id!=null]") but I am not working: s

+7
jquery jquery-selectors
source share
3 answers
 $("*[id]") 

should work, and - for the record -

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

- the opposite.

+14
source share
 $('[id]') 

This will capture all elements that have the id attribute.

Or get all the divs with the id attribute you can do:

 $('div[id]') 

has an attribute selector

+3
source share

Use it:

 $("div[id]") 

See jsfiddle .

0
source share

All Articles