Svitlana
Svitlana

Reputation: 23

Exclude one column from row's click event

I have code that dynamically generates rows of the table where the first column of each row is checkbox:

 let tr = $("<tr class='clickable-row'></tr>");
                    tr.append(`<td><input type="checkbox" class="checkbox"></td>`);
                    ...

OnClick event displays the details of the row.

$(document).on("click", ".clickable-row", function (e) {
                measurementManager.displayMeasurementsInfo(this);
            });
How to prevent function calling on the first column of each row?

Upvotes: 2

Views: 1520

Answers (1)

BenM
BenM

Reputation: 53198

You need to stop the event from propagating when the first <td> element is clicked. Add the following:

$(document).on('click', '.clickable-row td:first', function(e) { e.stopPropagation() });

Upvotes: 3

Related Questions