Problem using ID for jQuery .on(‘click’) 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
- The topic ‘Problem using ID for jQuery .on(‘click’) script’ is closed to new replies.