我似乎无法通过我的 Magento 网站将 jQuery 与 Prototype 分开。
我已经使用更改的标签等在 JsFiddle 上工作了,但是当我将它添加到我的 magento 站点时,我不断收到未捕获的语法错误。
页面位于http://www.asg.co.uk/gadgetclinic/how-it-works http://www.asg.co.uk/gadgetclinic/how-it-works
我正在使用的代码是:
<script type="text/javascript">
// First hide them all
$j("#how-it-works .step").hide();
function fades($j.step) {
$j div.fadeIn(300, function () {
if (!$j div.is('last-child')) {
fades($div.next());
}
else{
fades($j("#how-it-works .step:first-child"));
}
});
}
fades($("#how-it-works .step:first-child"));
</script>
HTML 代码是:
<div id="how-it-works">
<img src="{{skin url="images/how-it-works.png"}}" alt="How It Works" />
<div class="step"><h3>Get your box</h3><p>We'll send a suitably sized, pre-paid postage box for your device.</p></div>
<div class="step"><h3>Post your device</h3><p>Safely pack your device in your postage box and return it to us.</p></div>
<div class="step"><h3>Repair in process</h3><p>We will update you if need be whilst your device is repaired.</p></div>
<div class="step"><h3>Get your device</h3><p>Your device will be returned using the service you selected.</p></div>
</div>
任何人都可以帮助我系统地将所有必需的 $ 标签放入 $j 中,或者将 jQuery 与 Prototype 分离所需的任何内容吗?
打开你的jquery.x.x.x.js文件并将其添加到其最底部:jQuery.noConflict();
-
然后对于您的自定义 jQuery 代码,请使用以下内容:
jQuery(function($){
// Use jQuery with $(...)
$('#mySelector').hide();
/* your jquery code....*/
});
这就是我用 Magento 实现 jQuery 的方法。我更喜欢使用$
对于 jQuery 实例,因为它干净且熟悉。上面的代码包装器允许您执行此操作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)