0

The following code works fine....except.... I don't want to expand or callapse a row when the user clicks a checkbox. How can I block this? (I have jquery plugged in. I'm wondering if I can use this to solve the problem?)

<table class="table table-hover">
    <thead>
        <td>
            <h5>Select All:</h5>
        </td>
        <td>
            <h5><input type="checkbox" id="checkAll"></h5>
        </td>
    </thead>

    <tbody>
        <tr>
            <td colspan="2"> <input type="submit" , value="Replace Selected"> </td>
        </tr>
        <tr class="accordion-toggle" data-toggle="collapse" data-target="#tgt1">

            <td> Heading </td>
            <td><input type="checkbox" value="92340332" name="c1"></td>
        </tr>
        <tr>
            <td colspan="2">
                <div id="tgt1" class="collapse">content content</div>
            </td>
        </tr>
        <tr class="accordion-toggle" data-toggle="collapse" data-target="#tgt2">
            <td>Heading</td>
            <td><input type="checkbox" value="146735230" name="c2"></td>
        </tr>
        <tr>
            <td colspan="2">
                <div id="tgt2" class="collapse">content content</div>
            </td>
        </tr>
    </tbody>
</table>
Jake
  • 4,322
  • 6
  • 39
  • 83

1 Answers1

1

You'll need to use e.stopPropagation(); to your checkbox to prevent.

 $("myElement").on('click', function (e) { e.preventDefault(); })

or

$('input').click(function(e) {
    e.stopPropagation(); // prevents event e from going to parent
});
Vikas Jadhav
  • 4,597
  • 2
  • 19
  • 37