I wrote some simple jQuery code to try and hide rows of an html table based on the data inside one of the rows columns. The code I wrote works fine in all browsers except IE8, where it completely crashes (IE stops responding, tries to reload the tab and than reports that the page could not load).
If I include
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
the page no longer crashes, but it would be preferable to actually solve this issue rather than applying workarounds.
Here is a sample of the HTML table, and the jQuery code I am using to hide/show rows.
<table>
<thead> ... headers, table has 8 columns </thead>
<tbody>
<!--- The fifth column has a date I need to use to hide/show the rows -->
<tr> ... <td>9/27/2011</td> ... </tr>
...
</tbody>
</table>
function filterData() {
$("input[type='checkbox']:checked").attr("checked", false);
//This gets me the date to filter on
var filterDate = new Date($("#SelectedTimePeriod").val());
var minDate = new Date($("#SelectedTimePeriod").val());
minDate.setDate(filterDate.getDate() - 7 * $("#SelectedTimeRange").val());
var maxDate = new Date($("#SelectedTimePeriod").val());
maxDate.setDate(filterDate.getDate() + 7 * $("#SelectedTimeRange").val());
$("tbody tr td:nth-child(5)").each(function () {
var rowDate = new Date($(this).text());
if (rowDate.getTime() < minDate.getTime() || rowDate.getTime() > maxDate.getTime())
$(this).parent().hide();
else
$(this).parent().show();
});
}
The line that seems to crash IE8 is:
$(this).parent().hide();
Any help would be greatly appreciated, also if there is any more information I could provide that could be helpful please let me know.
This might not be an answer but I have made this jsfiddle and it works in all browsers (IE7->9, FF, Chrome).
I have made some optimizations to your code btw: