我见过类似于这个的其他一些跨浏览器问题,但它似乎归结为你使用jQuery的功能。这是我的两段jQuery,因为它们出现在我的HTML文档中。为了我的问题,我在两个单独的脚本标记中包含了它们。它是仅在Firefox中执行的第二个脚本标记。它不适用于Safari或Chrome,因此无法运行(甚至无法登录控制台)。为什么我的jQuery脚本只能在Firefox中工作?
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#product_accordion_custom a").click();
jQuery('#product_tabs_product_review_contents').appendTo('.product-collateral');
//toothbrush changing - image to menu
var colorDropDown = jQuery("select#attribute92");
var colorOptions = jQuery("select#attribute92 option");
jQuery("div.slide a").click(function(e){
var color = jQuery(this).find("img")[0].alt;
//colorDropDown.val(color).change();
for(var i = 0;i<colorOptions.length;i++){
s_color = colorOptions[i].innerText;
if(s_color==color){
colorDropDown.val(colorOptions[i].value).change();
}
}
});
});
</script>
<script type="text/javascript">
//toothbrush changing - menu to image
jQuery(document).on("click", "select#attribute92 option:selected", function(){
var selectorText = jQuery(this).text();
var tag = jQuery("img[alt='"+selectorText+"']");
jQuery("div.slide a").find(tag).click();
console.log(selectorText);
});
</script>
是的,上述内容在我的HTML文档中显示。 – sparecycle