How to get all elements with inline-style (style-attribute) start from a id of a div?

I want to get all elements which have an inline-style and searching for it inside a div and all their children.

Example

<div id="idofstartdiv">
    <span style="color:red;"></span>
    <div>
        <div style="color:green"><span style="color:yellow;"></span><span></span></div>
    </div>
</div>

I know I can get all the inline style by $("[style]") and I know to select the starting div by $("#idofstartdiv").

How can I combine both selectors?


You can combine them by simply doing:

$("#idofstartdiv[style]")

This will get the element which has an id of idofstartdiv along with a style attribute. For getting all children of that id as the parent with a style attribute you can do:

$("#idofstartdiv").find("[style]")

As mentioned in other answers, you can also do:

$("#idofstartdiv [style]")

$("#idofstartdiv [style]") is this is what you are asking for? if not can you provide an example of what you are expecting, am not clear with your question.

Another alternative-

$("[style]",  "#idofstartdiv")

This will also return all the elements which have style attribute under the parent div-id "idofstartdiv".