开发者

Magento product view's jQuery issue

开发者 https://www.devze.com 2023-03-23 18:45 出处:网络
I have included below code as css fix was not viable. It worked however now I cannot get pre-existing javascripts to work! Is there a reason why? I want to get the menu to toggle which was working bef

I have included below code as css fix was not viable. It worked however now I cannot get pre-existing javascripts to work! Is there a reason why? I want to get the menu to toggle which was working before so whe开发者_JAVA百科n clicked it toggles to another text.

this is the link if you need to have a look: http://www.playerspriority.wmetools.com/shop/index.php/pro-peptide.html

Thank you

<script type="text/javascript">
var n = $('select').length;
if(n == 2){
$('.product-collateral').attr('id','two-select-boxes');
}
$('div.zoom').attr('style','display:none');
$('p.zoom-notice').attr('style','display:none');
$('p.product-image-zoom').removeClass('product-image-zoom');
</script>


As far as I know magento uses prototype, which can lead to some problems with the $ variable. Run your jQuery code in no-conflict mode and try again.

jQuery(document).ready(function(){
    jQuery.noConflict();
    // replace $. with jQuery.
    //e.g.
    jQuery('.product-collateral).attr('id','two-select-boxes');

});

It is also a good practice to wrap your jQuery code into a ready function, to be sure the DOM is fully loaded before the jQuery code could run.

0

精彩评论

暂无评论...
验证码 换一张
取 消