Title: Having trouble with my JavaScript working
Last modified: August 31, 2016

---

# Having trouble with my JavaScript working

 *  Resolved [Morgan](https://wordpress.org/support/users/morganmcreynoldsgmailcom/)
 * (@morganmcreynoldsgmailcom)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/having-trouble-with-my-javascript-working/)
 * Hi,
 * Downloaded the plugin and am enjoying it. However, I am having trouble using 
   it to create some functionality that I want to achieve using WooCommerce and 
   the WooCommerce Product Bundles plugin, specifically.
 * In essence, I have some JavaScript that works when used outside the plugin, but
   when I move it into the plugin, it no longer works. Now it’s likely that this
   is an error on my side, but regardless, I can’t seem to get it to work. Any help
   would be appreciated.
 * Here is the code:
 * ‘
    <script type=”text/javascript”> jQuery( document ).ready(function() { jQuery(‘#
   smartphone-type’).on(‘change’, function() { console.log(“asdf”); if (jQuery(‘#
   smartphone-type’).val() == ‘iPhone’) { jQuery(‘.has_qty_input .bundled_qty’).
   val(‘1’); } else { jQuery(‘.has_qty_input .bundled_qty’).val(0); } }); }); </
   script> ‘
 * My site is dab-test.com. The above JavaScript – when working – should update 
   the quantity of one product (anything with the smartphone-type attribute) to 
   1 or 0 based on the selection of the type of smartphone made by the user.
 * Thanks for the help.
 * [https://wordpress.org/plugins/custom-css-and-javascript/](https://wordpress.org/plugins/custom-css-and-javascript/)

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

 *  [Potent Plugins](https://wordpress.org/support/users/hearken/)
 * (@hearken)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/having-trouble-with-my-javascript-working/#post-6931804)
 * Hi there,
    Thanks for getting in touch! Please remove the `<script>` tags from
   the start and end of your script – they aren’t necessary and will cause problems
   if included. That should fix things!
 * If you’d like to share your experience using the plugin, you can rate it at [https://wordpress.org/support/view/plugin-reviews/custom-css-and-javascript](https://wordpress.org/support/view/plugin-reviews/custom-css-and-javascript)
   🙂
 *  Thread Starter [Morgan](https://wordpress.org/support/users/morganmcreynoldsgmailcom/)
 * (@morganmcreynoldsgmailcom)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/having-trouble-with-my-javascript-working/#post-6931903)
 * Hi,
 * Thanks for the quick reply.
 * Setting the syntax of my code aside, here is what I am trying to achieve. On 
   my site, I use WooCommerce and a WooCommerce extension called Product Bundles.
 * I am somewhat undecided on a theme, but I know that I am going to use Product
   Bundles. And I want the functionality I described above to work regardless of
   the theme I choose (and I don’t want to have to re-code it or port the code to
   a new theme if I decide to switch themes).
 * So, with that context, is this the kind of thing that your plugin is designed
   to achieve / deliver?
 *  [Potent Plugins](https://wordpress.org/support/users/hearken/)
 * (@hearken)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/having-trouble-with-my-javascript-working/#post-6932022)
 * This plugin will allow you to run a custom Javascript on all pages of your site,
   and this should work regardless of which theme you use. As far as whether your
   Javascript code itself will be compatible with any theme, that really depends
   on your code and how it’s written, not on the plugin. Looking at your code, it
   looks like you’re using IDs and class names that shouldn’t be theme-dependent,
   but I can’t say for sure.

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

The topic ‘Having trouble with my JavaScript working’ is closed to new replies.

 * ![](https://ps.w.org/custom-css-and-javascript/assets/icon-256x256.png?rev=3061295)
 * [Custom CSS and JavaScript](https://wordpress.org/plugins/custom-css-and-javascript/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-css-and-javascript/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-css-and-javascript/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-css-and-javascript/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-css-and-javascript/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Potent Plugins](https://wordpress.org/support/users/hearken/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/having-trouble-with-my-javascript-working/#post-6932022)
 * Status: resolved