Title: JS Events
Last modified: May 2, 2020

---

# JS Events

 *  Resolved [codasys](https://wordpress.org/support/users/codasys/)
 * (@codasys)
 * [6 years ago](https://wordpress.org/support/topic/js-events/)
 * Hi,
 * I try to create an event listener for the described event uni_cpo_set_price_event.
   
   Is there an example how to use them?
 * I added the the following code:
 * document.addEventListener(“uni_cpo_set_price_event”, function(e) {
    console.log(
   e.detail); // Prints “Example of an event” console.log(“You knocked?”); });
 * But I get no output in the console (Firefox/Chrome).
 * Are the events on by default or to I need to activate them?
 * PS Maybe it will be good to extend the documentation with examples of how to 
   use them.

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

 *  Plugin Author [moomooagency](https://wordpress.org/support/users/moomooagency/)
 * (@moomooagency)
 * [6 years ago](https://wordpress.org/support/topic/js-events/#post-12768184)
 * Hi,
 * This event is attached to the body and created in jQuery (we use this dependency
   in the version 4). Therefore, you have to use jQuery as well and subscribe to
   events like this:
 * jQuery(document.body).on(‘uni_cpo_set_price_event’, function(){
    // your code});
 *  Plugin Author [moomooagency](https://wordpress.org/support/users/moomooagency/)
 * (@moomooagency)
 * [6 years ago](https://wordpress.org/support/topic/js-events/#post-12768188)
 * BTW, yes, it has one argument, it is a price.
    -  This reply was modified 6 years ago by [moomooagency](https://wordpress.org/support/users/moomooagency/).
 *  [donbloothoofd](https://wordpress.org/support/users/donbloothoofd/)
 * (@donbloothoofd)
 * [6 years ago](https://wordpress.org/support/topic/js-events/#post-12814007)
 * [@codasys](https://wordpress.org/support/users/codasys/) do you have the event
   working?
    So yes, i am very curious about your snippet!!
    -  This reply was modified 6 years ago by [donbloothoofd](https://wordpress.org/support/users/donbloothoofd/).
 *  Thread Starter [codasys](https://wordpress.org/support/users/codasys/)
 * (@codasys)
 * [6 years ago](https://wordpress.org/support/topic/js-events/#post-12814060)
 * Hi donbloothoofd,
 * I’m not pretty sure what so curious about my snippet, but YES it works.
    The 
   solution was written down by moomooagency (except that his code uses backtick
   instead of single qoute/double quotes)
 * jQuery(document.body).on(“uni_cpo_set_price_event”, function(e)
    { // List of
   parameters console.log(“DEBUG: uni_cpo_set_price_event triggered, get values”);
   const width = Number(jQuery(“#uni_cpo_myvalue-field”).val()); ….. // or do something
   with e })
 * Regards

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

The topic ‘JS Events’ is closed to new replies.

 * ![](https://ps.w.org/uni-woo-custom-product-options/assets/icon-256x256.jpg?rev
   =1764217)
 * [Product Options and Price Calculation Formulas for WooCommerce – Uni CPO](https://wordpress.org/plugins/uni-woo-custom-product-options/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/uni-woo-custom-product-options/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/uni-woo-custom-product-options/)
 * [Active Topics](https://wordpress.org/support/plugin/uni-woo-custom-product-options/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/uni-woo-custom-product-options/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/uni-woo-custom-product-options/reviews/)

## Tags

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

 * 4 replies
 * 3 participants
 * Last reply from: [codasys](https://wordpress.org/support/users/codasys/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/js-events/#post-12814060)
 * Status: resolved