为什么IE7不认为这两个字符串是平等的?(Why doesn't IE7 think these two strings are equal?)

编程入门 行业动态 更新时间:2024-10-22 07:29:17
为什么IE7不认为这两个字符串是平等的?(Why doesn't IE7 think these two strings are equal?)

我有一个事件处理程序,将从相应的复选框的列表中删除一个元素未选中。 在复选框的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

更多推荐

本文发布于:2023-07-08 19:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1080240.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:这两个   字符串   平等   strings   equal

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!