jquery accessing all elements who have id attribute
javascript, jquery
Solution
Your code works just fine, but you can remove the `*` from the selector.
Other valid options:
$("div").find("[id]").each(function() { alert(this.id) });
LIVE DEMO
Or this:
$("div *").filter("[id]").each(function() { alert(this.id) });
Live DEMO
Or this:
$("div [id]").each(function() { alert(this.id) }); // which I think is the best
Live DEMO
Problem
I want to get all elements from a div who have `id attribute`, means i want to do something like: ``` $("div").find("*[id]").each(function() { alert(this.id) }); ``` but this is not working , can anybody help me pls?