How To Use jQuery In Magento?

By default, Magento uses the Prototype javascript library. You can also integrate the javascript library “jQuery” in your Magento store. There is some problem to integrating jQuery in Magento, you might get some javascript conflict errors as your Magento  store is using two javascript libraries one is prototype.js and another one id jQuery.js at a same time. This is caused because prototype as well as jQuery uses “$” as a function or variable name. Don’t worry about it because jQuery has a solution for such kind of conflict case.

Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery case, $ is just an alias for jQuery, so all functionality is available without using $. If we need to use another JavaScript library alongside jQuery, we can return control of $ back to the other library with a call to $.noConflict(). Old references of $ are saved during jQuery initialization; noConflict() simply restores them.

this is what jQuery Says about the Conflict Read More

Here is the steps how to use the JQuery in Magento

Step 1. Download jQuery from jquery.com
Step 2. Copy the jquery file to the following directory: skin/frontend/default/your_custom_theme/js/
Step 3. Navigate to the app/design/frontend/default/your_custom_theme/layout/page.xml and open it in the editor of your choice.
Step 4. In page.xml file, search for block with name “head” and add the following code inside it.

<action method="addItem"><type>skin_js</type><name>js/jquery.js</name></action>

Step 5. Removing conflict between two javascript libraries
Navigate to the app/design/frontend/default/your_custom_theme/template/page/head.phtml and open it in the editor of your choice
Add the following code at the end of this page

<script type="text/javascript">
jQuery.noConflict();
</script>

You have done. You can use jQuery in your Magento store without any conflict.

Comments
  1. Garcinia Cambogia Supplement

    I really like your blog.. very nice colors & theme.
    Did you design this website yourself or did you hire someone
    to do it for you? Plz reply as I’m looking to create my own blog and would like to know where u got this from. appreciate it

    • admin

      If you want to start your own blog you can choose the wordpress themes from the Magazine3. It has alot of options for the blog as well as for the ecommerce.

      Thanks

  2. Randall

    Үour own article pгoѵіdeѕ confiгmed necessary to myself.
    It’s eхtrеmelу informative аnd
    you are certainly extremely ωell-infoгmed of this typе.
    You hаve got exρosed mу рersonal eyеѕ
    for yоu tо various viеws оn this κind of mattеr togetheг with intгiguіng аnd reliable wrіtten content.

  3. Buy Garcinia Cambogia

    These are really fantastic ideas in regarding blogging.
    You have touched some good things here. Any way keep up wrinting.

  4. Pure GCE REviews

    If you want to get much from this article then you have to apply these methods to your own weblog.

  5. Bradyquick

    I rarely comment, however i did a few searching and wound up here How To Use jQuery In Magento |
    Expertwebadvisor. And I actually do have some questions for you if it’s allright. Could it be just me or does it look as if like some of the comments come across like left by brain dead visitors? :-P And, if you are writing on additional sites, I would like to keep up with anything new you have to post. Would you make a list of all of your social pages like your twitter feed, Facebook page or linkedin profile?

ADD YOUR COMMENT

*