Strangely onclick of <tr>
is not working in my case when I put it on JSFiddle http://jsfiddle.net/dad5m5vb/
This is the HTML:
<form id="form_city" action="">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th>City Id</th>
<th>City Name</th>
</tr>
<tr id="row1" onclick="rowClicked(this);">
<td>1</td>
<td>New York</td>
</tr>
<tr id="row2" onclick="rowClicked(this);">
<td>2</td>
<td>Los Angeles</td>
</tr>
<tr id="row2" onclick="rowClicked(this);">
<td>3</td>
<td>Chicago</td>
</tr>
</table>
</form>
This is the JavaScript:
function rowClicked(clickedRow) {
alert(clickedRow);
}
On clicking on any row (except the header), the javascript function should be called. But I am not getting the alert from the javascript function. Why?