3
I have a map of Brazil, in an SVG, where I would like to present a div
next to each state when clicking on it.
I managed to work the color change with hover
using the ID
of each state of Brazil:
function highlight_map_states(){
if($(".states_section").length>0){
$(".states_section .list_states .item .link").hover(function(){
var a="#state_"+$(this).text().toLowerCase();
$(a).attr("class","state hover")
},function(){
var a="#state_"+$(this).text().toLowerCase();
$(a).attr("class","state")
})
}
};
How do I have one click on each state to make one appear div
?
Note: You can’t put all the code here because the question has a maximum character size, but it gets a demo on Codepen.
Got it Zuul!! And how do I create a different div for each state?? Excuse the ignorance rs because I don’t know any javascript! Thank you very much ;)
– mdesigner
@I don’t know what you want them for
div
nor what will be inside each one to advise you in the best way. But it would not be more practical and simple to have thediv
in HTML, such as the examples in the answer, and when using them, call the.show()
to present them ? Anyway, there are two examples in Jsfiddle for: Create DIV with Javascript and create DIV with jQuery.– Zuul
Thank you very much Zuul!!
– mdesigner