我正在尝试使用一个简单的jQuery脚本来处理我的magento产品页面。然而,在将jQuery脚本添加到XML并因此magento能够在标题中读取和添加jQuery脚本之后...脚本仍然无效。然后我尝试将脚本放入chrome控制台,它运行正常。
$j(document).ready(function(){
$j("#ship").show();
$j("#details").hide();
$j("#sizing").hide();
$j(".ship").css("text-decoration","underline");
$j(".ship").click(function(){
$j(".ship").css("text-decoration","underline");
$j(".details").css("text-decoration","none");
$j(".sizing").css("text-decoration","none");
$j("#ship").show();
$j("#details").hide();
$j("#sizing").hide();
});
$j(".details").click(function(){
$j(".ship").css("text-decoration","none");
$j(".details").css("text-decoration","underline");
$j(".sizing").css("text-decoration","none");
$j("#ship").hide();
$j("#details").show();
$j("#sizing").hide();
});
$j(".sizing").click(function(){
$j(".ship").css("text-decoration","none");
$j(".details").css("text-decoration","none");
$j(".sizing").css("text-decoration","underline");
$j("#ship").hide();
$j("#details").hide();
$j("#sizing").show();
});
});
答案 0 :(得分:2)
使用Jquery.noConflict()函数。它将解决问题
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($) {
// Code that uses jQuery's $ can follow here.
});
// Code that uses other library's $ can follow here.
</script>