-2

I am using the jQuery plugin "Selecter" and I try to count selected elements. I tried to count elements with the css attribute selected, but I can't get it right.

$("span[style='selected']").length

This is how my HTML looks like (one is selected):

    <div class="selected-options">
       <span class="selecter-item selected" data-value="wtZyXCj99F7kWqhpL">One</span>
       <span class="selecter-item" data-value="gZGMcg8oDHpQsSHui">Two</span>
    </div>

Any help would be greatly appreciated.

2

1 Answer 1

4

selected is class and not style. so use:

$("span.selected").length
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.