How to use jQuery in magento?
Quick and easy steps on how to use jQuery in magento are as follows.
Step 1: Download “jQuery js” file and upload it to the magento “js” folder.
Step 2: Now open the file “page.xml” at Magento/app/design/frontend/default/default/layout/page.xml.
Step 3: Now add following line inside block “html_head” before end tag.
- <action method=”addJs”>%MINIFYHTMLba657fa99a7962529700c5b675c247663%</action>
Step 4: Now you’ll need to clear that cache to see the effect take place, The layout files are normally cached.
Step 5: Now you need to include jQuery on page. You could perform this by adding a new line to the page.xml file, or you could open the common head.phtml file at Magneto/app/design/frontend/default/default/template/page/html/head.phtml – and add following code there for jQuery. This code will noConflict and write code in that mode. Basically you replace the normal “$” with $j.
- var $j = jQuery.noConflict();
- /* following three lines are for testing purpose. You can remove them as it’s not required. */