Title: Handle set-cookie button click
Last modified: August 30, 2016

---

# Handle set-cookie button click

 *  [pinyol](https://wordpress.org/support/users/pinyol/)
 * (@pinyol)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/handle-set-cookie-button-click/)
 * I think there is an error with the setter of the event ‘click’ in front.js file.
   
   The event is looking for an element with ‘cn-set-cookie’ class defined and I 
   didn’t find an element with this class in the generated html and the cookie message
   don’t dissapear when I click on it.
 * If I change the event to find an element with ID attribute like ‘cn-accept-cookie’
   the cookie message dissaper correctly when I click on it.
 * Summary
    **Does not work** // handle set-cookie button click $( document ).on(‘
   click’, **‘.cn-set-cookie’**, function ( e ) { e.preventDefault(); $( this ).
   setCookieNotice( $( this ).data( ‘cookie-set’ ) ); } );
 * **Does work**
    // handle set-cookie button click $( document ).on( ‘click’, **‘#
   cn-accept-cookie’**, function ( e ) { e.preventDefault(); $( this ).setCookieNotice(
   $( this ).data( ‘cookie-set’ ) ); } );
 * Is this correct?
 * [https://wordpress.org/plugins/cookie-notice/](https://wordpress.org/plugins/cookie-notice/)

The topic ‘Handle set-cookie button click’ is closed to new replies.

 * ![](https://ps.w.org/cookie-notice/assets/icon-256x256.png?rev=2466385)
 * [Compliance by Hu-manity.co](https://wordpress.org/plugins/cookie-notice/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookie-notice/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookie-notice/)
 * [Active Topics](https://wordpress.org/support/plugin/cookie-notice/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookie-notice/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookie-notice/reviews/)

## Tags

 * [class](https://wordpress.org/support/topic-tag/class/)
 * [id](https://wordpress.org/support/topic-tag/id/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)

 * 0 replies
 * 1 participant
 * Last reply from: [pinyol](https://wordpress.org/support/users/pinyol/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/handle-set-cookie-button-click/)
 * Status: not resolved