Title: Adding JavaScript
Last modified: April 19, 2021

---

# Adding JavaScript

 *  Resolved [jokubas2000k](https://wordpress.org/support/users/jokubas2000k/)
 * (@jokubas2000k)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/adding-javascript-10/)
 * I have a JavaScript code snippet I’d like to add to my website:
 *     ```
       $(document).ready(function() {
   
           $('.input-text').on('input', function() {
   
               var valueLength = $(this).val().length;
   
               if (valueLength > 0 ) {
                   $(this).closest('.form-row').addClass('display-floating-label');
               } else {
                   $(this).closest('.form-row').removeClass('display-floating-label');
               }
   
           });
   
       });
       ```
   
 * The code snippet adds a class to WooCommerce checkout fields if the input value
   is greater than 0 for styling purposes.
 * I tried adding it at **Appearance > Customize > Custom CSS/JS** in the Custom
   JS text box but it does not work. Why?
 * Are there any other ways to add JS to the website?

The topic ‘Adding JavaScript’ is closed to new replies.

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

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [jokubas2000k](https://wordpress.org/support/users/jokubas2000k/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/adding-javascript-10/)
 * Status: resolved