jquery .map不适用于IE 10 [英] jquery .map is not working on IE 10
问题描述
我有这个jquery代码:
I have this jquery code:
$("#tf_zoom").live("click", function () {
var n = $(".tf_thumbs").find("img").attr("src");
var modelid = n.substr(43);
$.post("models/get_gallery", {
"modelid": modelid
}, function (data) {
var imagespathes = $(data).map(function (key, url) {
return ({
href: '<?php echo base_url();?>assets/uploads/files/' + url
});
});
console.log(imagespathes);
$.fancybox.open(imagespathes);
}, "json");
});
这是我的html:
<div id="tf_thumbs" class="tf_thumbs">
<span id="tf_zoom" class="tf_zoom"></span>
<img id="dynam" src="<?php echo base_url();?>assets/uploads/files/<?php echo $firstthumb;?>" alt="Thumb1"/>
</div>
好的,现在我的问题是此代码无法在 IE 10上运行令人惊讶的是,除了 FF和谷歌浏览器
Okay, now my problem is that this code is not functioning on IE 10 and surprisingly it's working like a charm on IE 9, IE 8, IE 7 besides FF and Google Chrome
IE 9,IE 8,IE 7 上的魅力>我读了很多关于这个问题的事情,但对我没什么用。
那么,有什么解决方案吗?
非常感谢您的帮助。
I read many things about this issue but nothing worked for me. So, is there any solution for it. your help is really appreciated.
更新1 :我使用的是jquery版本 1.7
Update 1 : I am using jquery version 1.7
推荐答案
也许这个提示可以帮到你:
Perhaps this hint will help you:
我注意到了 .map($(select)。get(0).options)
在IE10中不起作用,但 .map($(select:first) >选项))
将。这是因为在ie10 .options中返回带有迭代选项的select节点。
I have noticed that .map( $("select").get(0).options )
will not work in IE10 but .map( $("select:first >option") )
will. This is because in ie10 .options returns a select node with an iteration of options.
所以看看在IE10中返回了什么数据,也许它也不是一个数组。如果是这样,也许你可以做一些像 $(新的数组(数据))。map(...
这将满足所有浏览器
So see what data is returning in IE10, perhaps it too is not an array. And if so perhaps you can do something like $(new Array(data)).map(...
which will satisfy all browsers
这篇关于jquery .map不适用于IE 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!