Ron Jb
Ron Jb

Reputation: 77

if body class hasclass add js if not add this js

Anybody can tell me what is wrong here? I have a conflict with

ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js,

So that's why I need noconflict to true,but if I assigned it to all pages my slidingpanels doesn't work.I really need to have the sliding panel script on pages that isn't virtuemart help

<?php
    if ($("body").hasClass("option-com-virtuemart")) {
       addScript("noflict.js");}
      else {
      addScript("slidingpanel.js");} 
    ?>

Thanks in advance

Upvotes: 0

Views: 367

Answers (2)

Mahesh.D
Mahesh.D

Reputation: 1689

You have written jQuery code inside the PHP block, free from that and try again.

Upvotes: 0

Quentin
Quentin

Reputation: 944520

if ($("body").hasClass("option-com-virtuemart")) { appears to be JavaScript (using the jQuery library). It isn't PHP so it can't run inside a <?php ?> block.

Upvotes: 5

Related Questions