Magento 2 – Add JS File to Catalog Page

catalogjavascriptmagento2requirejsrequirejs-config.js

I am using Magento 2.2.1. I want to add a js file to change one special span tag content with CSS class "price" on the catalog page. I was using document.getelementnByClass.. for my js development. and my question is how to accept that in my Magento 2 project

Best Answer

You can use requireJs in your phtml File and use jquery for that

<script>
    require([
        'jquery',
    ], function ($) {
       //here write your code :) 
    });
</script>
Related Topic