Title: where to add jquery code
Last modified: August 22, 2016

---

# where to add jquery code

 *  Resolved [ac1643](https://wordpress.org/support/users/ac1643/)
 * (@ac1643)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/where-to-add-jquery-code/)
 * Hi
 * I have some jquery code I would like to add to enable smooth scrolling to anchor
   tags. Couldt you please tell me where I need to put this code in the theme files?
   It is:
 * ——————————–
    {cms_jquery}
 * <script type=”text/javascript”>
    jQuery(document).ready(function($) { $(“.scroll”).
   click(function(event) { event.preventDefault(); $(‘html,body’).animate( { scrollTop:
   $(this.hash).offset().top } , 1000); } ); } ); </script> ——————————–
 * Thanks

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [vladff](https://wordpress.org/support/users/vladff/)
 * (@vladff)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/where-to-add-jquery-code/#post-5572091)
 * Since I guess you don’t plan to update the theme, you can put it in scripts.js(
   edit: without the <script> tags).
 * Though you’ll probably want to use the code that has already been available in
   the theme for some time now: [https://themes.svn.wordpress.org/moesia/1.17/js/scripts.js](https://themes.svn.wordpress.org/moesia/1.17/js/scripts.js)(
   last block)
 *  Thread Starter [ac1643](https://wordpress.org/support/users/ac1643/)
 * (@ac1643)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/where-to-add-jquery-code/#post-5572116)
 * Cheers for the quick response, brilliant.
 * 2 things:
 * 1)If i update moesia to a newer version in the future, presumably I would have
   to add it to js.scripts adain? code again?
 * 2)With the code above, i think you need to add class=”scroll” along with the 
   href to enable the scrolling mode. With the code in the link you provided, does
   this require a class definition or does it just make all anchor movements scroll?
 * If I was to use your code presumably I also copy it to the scripts.js file?
 * Thanks
 *  [vladff](https://wordpress.org/support/users/vladff/)
 * (@vladff)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/where-to-add-jquery-code/#post-5572133)
 * 1) Yeap. Unless you use a child theme.
    2) You don’t need a class for the code
   that I linked to, you need one for yours.
 * Yeap, same place as it actually is in the theme. Not sure if you noticed, but
   the file I linked to is the scripts.js from the latest version.
 *  Thread Starter [ac1643](https://wordpress.org/support/users/ac1643/)
 * (@ac1643)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/where-to-add-jquery-code/#post-5572159)
 * I’ve added your code in, everything’s working fine.
 * Many thanks
 *  [fearlesschampion](https://wordpress.org/support/users/fearlesschampion/)
 * (@fearlesschampion)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/where-to-add-jquery-code/#post-5572540)
 * Hey guys, I’m trying to load a popup effect but it won’t work! I’ve checked the
   code and it works when I run it in netbeans. But it won’t work on my website 
   with Moesia?
 * I’ve checked and scripts.js has been loaded on the page where it is supposed 
   to do it’s magic.
 * This is my code:
 *     ```
       jQuery(function($) {
         var terms = $('#terms');
         var agree = $('#agree');
         var overlay = $('#overlay');
         var popupBox = $('#popupBox');
   
         terms.click(function() {
           overlay.fadeIn(300);
           popupBox.fadeIn(300);
         });
   
           $('#agree, #overlay').click(function() {
               overlay.fadeOut(300);
               popupBox.fadeOut(300);
           });
       });
       ```
   

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘where to add jquery code’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/moesia/1.54/screenshot.png)
 * Moesia
 * [Support Threads](https://wordpress.org/support/theme/moesia/)
 * [Active Topics](https://wordpress.org/support/theme/moesia/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/moesia/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/moesia/reviews/)

## Tags

 * [file](https://wordpress.org/support/topic-tag/file/)

 * 5 replies
 * 3 participants
 * Last reply from: [fearlesschampion](https://wordpress.org/support/users/fearlesschampion/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/where-to-add-jquery-code/#post-5572540)
 * Status: resolved