Title: Problem using ID for jQuery .on(&#8216;click&#8217;) script
Last modified: September 26, 2020

---

# Problem using ID for jQuery .on(‘click’) script

 *  [Philnicholl](https://wordpress.org/support/users/philnicholl/)
 * (@philnicholl)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/problem-using-id-for-jquery-onclick-script/)
 * Hi,
 * Many thanks for this plugin.
 * I’m trying to use clicks on countries to hide and show div containers relating
   to each country.
 * On the maps, each country imapsContainer-group seems to have an id. For the UK
   it is ‘id-421’
 * I’m using a simple jQuery script along the lines of:
 *  $(“#id-421”).on(‘click’, function (e) {
    $(‘.country-container#mygivenUKid’).
   fadeIn(); });
 * (My page content containers have the class ‘country-container’ and I’m giving
   each container a specific ID such as ‘mygivenUKid’.)
 * This works fine with a general selector like .imapsContainer-group :
 *  $(“.imapsContainer-group”).on(‘click’, function (e) {
    $(‘.country-container#
   mygivenUKid’).fadeIn(); });
 * but does not work with the specific id : “id-421”
 * It may be that the id does not exist in the DOM until it is clicked or it may
   be something to do with the hyphen or the string ‘id’
 * Could you give me any idea why this isn’t working?
 * Thanks again,
 * Phil Nicholl

Viewing 1 replies (of 1 total)

 *  [Carlos Moreira](https://wordpress.org/support/users/carlosmoreirapt/)
 * (@carlosmoreirapt)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/problem-using-id-for-jquery-onclick-script/#post-13460886)
 * Hi Phil. Those ids are not reliable to attach events to. This is better handled
   in the Pro version.
    Since you’re now using the Pro version, we can follow up
   in the ticket you opened recently. I’ll close this one. Greetings, Carlos

Viewing 1 replies (of 1 total)

The topic ‘Problem using ID for jQuery .on(‘click’) script’ is closed to new replies.

 * ![](https://ps.w.org/interactive-geo-maps/assets/icon-256x256.png?rev=3115060)
 * [MapGeo - Interactive Geo Maps](https://wordpress.org/plugins/interactive-geo-maps/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/interactive-geo-maps/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/interactive-geo-maps/)
 * [Active Topics](https://wordpress.org/support/plugin/interactive-geo-maps/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/interactive-geo-maps/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/interactive-geo-maps/reviews/)

## Tags

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

 * 1 reply
 * 2 participants
 * Last reply from: [Carlos Moreira](https://wordpress.org/support/users/carlosmoreirapt/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/problem-using-id-for-jquery-onclick-script/#post-13460886)
 * Status: not a support question