[英]Why is IE8 adding whitespace inside a JS string concat?
I'm writing a quick script to show and hide a ul and its contents - basically a dropdown menu. 我正在编写一个快速脚本来显示和隐藏ul及其内容-基本上是一个下拉菜单。 Problem I'm having is in the code below, line 2:
我遇到的问题在下面的代码中,第2行:
$('#mainMenu ul li').mouseenter(function() {
var dropTab = 'ul.' + $(this).attr("id") + 'Dropdown';
alert(dropTab);
$(dropTab).slideToggle();
});
Works fine in FF, but in IE8 the dropTab string has whitespace between the second and third elements ie it outputs: 在FF中工作正常,但在IE8中dropTab字符串在第二个和第三个元素之间具有空格,即它输出:
ul.someId Dropdown
when I'm looking for: 当我寻找时:
ul.someIdDropdown
Like I said, works fine in FF, but am curious as to where the whitespace is coming from, as it stops the function from performing... 就像我说的那样,在FF中可以正常工作,但是对空格来自哪里感到好奇,因为它使函数无法执行...
Any suggestions welcome - happy to consider an alternative method 欢迎任何建议-乐意考虑其他方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.