I have created a table with one row that includes the title of the month and a cell containing an inner table with multiple rows and cells. I want to display the content of the second cell in the second table as a modal box or alert dialog when it is clicked.
Currently, the alert box pops up when either cell is clicked. However, I only want to trigger the alert dialog when the second cell is clicked.
Below is my table setup:
$("table table tr").click(function() {
alert($(this).children("td").text());
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<html>
<head>
<style>
table,
th,
td {
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<th>Month</th>
</tr>
<tr>
<td>January
<table>
<tr>
<td>Do not show details of this cell</td>
</tr>
<tr>
<td>Show details of this cell when clicked</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>