我有一个事件处理程序,将从相应的复选框的列表中删除一个元素未选中。 在复选框的click事件处理程序中,首先复制该复选框的标签值:
var label = $(this).next().html();然后,我迭代列表项并将它们与标签进行比较:
$("#sortable li").each(function() { if ($(this).html() === label) { $(this).remove(); } });在Internet Explorer 8和Firefox中,它的工作原理与我所期望的完全相同。 在Internet Explorer 7中,它没有。 “if”语句中的条件从来就不是真的。 我在这里错过了什么?
通过请求,比较的字符串是“Charge”和“Charge”。
I have an event handler that will remove an element from a list of the corresponding checkbox is unchecked. In the handler for the click event for the checkbox, first I copy the value of the label for that checkbox:
var label = $(this).next().html();Then, I iterate over the list items and compare each of them to that label:
$("#sortable li").each(function() { if ($(this).html() === label) { $(this).remove(); } });In Internet Explorer 8 and in Firefox, this works exactly as I'd expect. In Internet Explorer 7, it does not. The condition in the "if" statement is never true. What am I missing here?
By request, the strings being compared are, "Charge" and "Charge" in one case.
最满意答案
为什么不使用脚本调试器并确切地知道为什么这种比较是错误的? 只需在if中设置断点并观察变量即可。
IE8内部脚本调试器将帮助您,只需切换到兼容模式即可在IE7 javascript运行时运行脚本
Why don't you use the Script Debugger and see exactly why that comparison is false? Just set a breakpoint in the if and watch the variables.
The IE8 internal script debugger will help you, just switch to compatibility mode to run the script in the IE7 javascript runtime
更多推荐
发布评论