1

1. Why my code doesn't work with Bootstrap checkboxes:

The javascript below would work perfectly if (bootstraps checkboxes) had the property "checked" in the inputs, but it is setting the class="checked" in the parent span. As below:

<span class="checked">
   <input type="checkbox" value="9577" class="overtimeapproval">
</span>

This javascript returns an array with all the rows that I need:

$("#mytable:has(.overtimeapproval:checked)").dataTable().fnGetNodes();

2. What I suppose I have to do for Bootstrap checkboxes

To make the same javascript working with bootstrap checkboxes I need something like:

todo: $("#mytable:has(.overtimeapproval:parent:span:checked)").dataTable().fnGetNodes();

How can I do the jquery selector above?

2
  • 1
    you might find this useful: stackoverflow.com/questions/18501802/…
    – JGV
    May 22, 2015 at 0:12
  • This doesn't really help much, I need a selector to filter when the parent span has the class ".checked" @VimalanJayaGanesh
    – Roger
    May 22, 2015 at 0:22

2 Answers 2

2
$("#mytable:has(.overtimeapproval:parent.checked)").dataTable().fnGetNodes();

I think this can help you.

3
  • No, it is not working, "checked" is a class of the span object, how can I select when there is a ".checked" class? @lightbringer
    – Roger
    May 22, 2015 at 0:20
  • 1
    doesn't has() function do that? otherwise you can go from top to bottom instead of going backward, something like #mytable:has(span.checked input.overtimeapproval) May 22, 2015 at 0:27
  • This javacript worked perfectly! Even being a "Bootstrap checkbox": $($("#mytable").dataTable().fnGetNodes()).has('.overtimeapproval:checked')
    – Roger
    May 22, 2015 at 0:49
0

I could do exactly what I needed with the javascript below:

$($("#mytable").dataTable().fnGetNodes()).has('.overtimeapproval:checked')

It seems that Bootstrap checkboxes work properly with the :checked selector.

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.