I have been utilizing this interactive map from Wolf's website, but I am interested in incorporating a secondary list of countries alongside the existing one as the base for the script. However, due to presentation reasons, the second menu cannot reside in the same DIV as the map. I have been exploring the JQuery documentation to figure out how to trigger an action on a different element than the one currently selected, but my attempts so far have not been successful.
The current script appears like this:
$(document).ready(function(){
var new_map='<span class="map"><span class="s1" /><span class="s2" /><span class="s3" /><span class="s4" /><span class="s5" /><span class="s6" /><span class="s7" /><span class="s8" /><span class="s9" /><span class="s10" /><span class="s11" /><span class="s12" /><span class="s13" /><span class="s14" /><span class="s15" /><span class="s16" /><span class="s17" /><span class="s18" /></span>';
var new_bg=$("<span>");
new_bg.addClass("bg");
$("#europe li a").append(new_map);
$("#europe li a").append(new_bg);
});
What I aim to achieve is to trigger the same action when hovering over another element that is not #europe li a. To accomplish this, I tested the following code:
$(document).ready(function(){
var new_map='<span class="map"><span class="s1" /><span class="s2" /><span class="s3" /><span class="s4" /><span class="s5" /><span class="s6" /><span class="s7" /><span class="s8" /><span class="s9" /><span class="s10" /><span class="s11" /><span class="s12" /><span class="s13" /><span class="s14" /><span class="s15" /><span class="s16" /><span class="s17" /><span class="s18" /></span>';
var new_bg=$("<span>");
new_bg.addClass("bg");
$("#carteeurope li a").append(new_map);
$("#carteeurope li a").append(new_bg);
$("#menudroite li a").hover(function(){
$(new_map).appendTo("#carteeurope li a");
$(new_bg).appendTo("#carteeurope li a");
});
});
While this does produce some effect, it doesn't quite achieve the desired outcome - the map seems to move, but not to the correct positions (some countries end up with a white background after multiple hovers on the second menu).
Your assistance in resolving this issue would be greatly appreciated!
Kind regards.
PS: Here are some relevant HTML and CSS snippets.
The original list
<div id="b">
<ul id="europe" class="bottom five_columns">
<li id="europe1"><a href="#" title="Albania">Albania</a></li>
<li id="europe2"><a href="#" title="Andorra">Andorra</a></li>
<li id="europe3"><a href="#" title="Austria">Austria</a></li>
...
The additional menu
<div id="menudroite">
<ul>
<li><a href="#">Accueil</a></li>
<li><a href="#" title="France">France</a></li>
<li><a href="#" title="Grèce">Grèce</a></li>
...
The original CSS
#europe,#europe span.bg{background:transparent url('europe-600px.png') no-repeat -9999px 0}
#europe{position:relative;top:0;left:0;display:block;background-position:0 -966px;list-style:none}
#europe *{padding:0;margin:0;border:0 none;outline:0 none}
#europe li{cursor:pointer}
#europe li span{position:absolute;display:block;width:0;height:0;z-index:15}
#europe li a span.bg{z-index:3}
#europe li .map{top:0;left:0}
...
#europe li span{position:absolute;display:block;top:0;left:0;width:0;height:0;z-index:15}
#europe1 a:hover .bg{top:395px;left:303px;width:20px;height:40px;background-position:-10px -10px} #europe1 .s1{top:401px;left:303px;width:15px;height:32px} #europe1 .s2{top:397px;left:305px;width:8px;height:4px} #europe1 .s3{top:418px;left:318px;width:4px;height:9px}
#europe2 a:hover .bg{top:385px;left:133px;width:5px;height:6px;background-position:-35px -10px} #europe2 .s1{top:383px;left:131px;width:9px;height:10px}
...