Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onclick event on disabled <td> only works when clicking text but not when clicking other area in td( ie10, ie11 issue)

I have this html code below.

<table border="1" style="width:100%">
 <tr> <th>Col</th></tr>
  <tr><td onclick="alert('1');" disabled="disabled"><label>One<br></label></td></tr>
  <tr><td onclick="alert('2');" disabled="disabled"><label>Two<br></label></td></tr>
  <tr><td onclick="alert('3');" disabled="disabled"><label><br></label></td></tr>
</table>

The above code works in Chrome and Microsoft Edge means it shows alert on clicking anywhere inside td tag in all 3 tds.
But in IE10, IE11 it works only when td contains some data, like in the above code 3rd row doesn't give alert and for other tds it only works when we click on text not when clicking any other area inside td other than text.

This code in part of my large application. I just want to know is this a known bug in IE, if yes than can anybody provide me link of that bug.
Or am I missing something in code that causes the issue. Since it is a part of large application I want add less code so that it wont affect the rest app.

Any help would be appreciated

like image 383
singhakash Avatar asked Nov 07 '22 21:11

singhakash


1 Answers

According to the docs: https://msdn.microsoft.com/en-us/library/ms533732(v=vs.85).aspx,

Disabled elements do not respond to mouse events

I tested your code in IE11 and it works without the disabled property. I thought it might have been a td-specific issue so I added the onclick to a div and it works as well, as long as there is no disabled attribute.

Test this on IE11

like image 138
Josan Iracheta Avatar answered Nov 15 '22 12:11

Josan Iracheta