Ticket #1211 (closed bug: fixed)
$('td').bind("click", function(){}); doesn't work in internet explorer 7
| Reported by: | tallphil | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.1.3 |
| Component: | event | Version: | 1.1.2 |
| Keywords: | table, bind, click, onclick | Cc: | |
| Blocking: | Blocked by: |
Description
I'm trying to make a clickable table to save preferences using the bind("click" function with a table.
Link: http://www.tallphil.co.uk/feeds/
Snippet:
$('td').bind("click", function(){
if($(this).css('background-color') == 'rgb(237, 252, 235)'){
$(this).css('background-color','rgb(245, 207, 207)');
selected[$(this).attr('id')] = false;
}
});
The code works perfectly in firefox, but has no effect in internet explorer 7. I presume that it's a problem with using the onclick handler with a td element, any way to get around this?
Cheers
Phil
Change History
comment:2 Changed 2 years ago by Oaresome
I had this same problems when I was trying to use the expand function, not when you click a row but when you click a cell. I ended up putting <a> within the cell to get it working in IE. Worked fine in firefox. Javascript as below:
<script type="text/javascript">
$(document).ready(function(){
$("#report tr:odd").addClass("odd");
$("#report tr:not(.odd)").hide();
$("#report tr:first-child").show();
$("#report tr.odd a").click(function(){
//$("#report tr.odd td.comments").click(function(){
$(this).closest("tr").next("tr").toggle();
$(this).find(".arrow").toggleClass("up");
});
//$("#report").jExpand();
});
</script>
Hope this helps.
comment:3 Changed 2 years ago by rwaldron
Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!
Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, I've created this boilerplate: http://jsfiddle.net/rwaldron/da3nM/ Open the link and click to "Fork" in the top menu.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

This is working for me with jQuery 1.1.3a/latest SVN