2
I am working with a map of Brazil in SVG, and I need that when you click on a state, it add the "active" class and remove the "active" class from the others. It also has the function of adding the state name to an input.
Example:
<path id="Santa Catarina" class="BR-SC RegiaoSul str1" d="M101205 160059l0 -33 -32 -32 32" />
<script type="text/javascript">
$(docutment).ready(function() {
$(".str1").click(function(){
var state = $(this).attr("id");
$(".str1").removeClass("active");
$(this).addClass("active");
$("input[name=estado]").val( state );
});
});
</script>
With jQuery not working of course, I would like to do this in javascript, someone can help me?
Is it an open source svg library from the map? What are you using? If you can post an example on jsFiddle
– Fernando Leal
I only have the SVG file, the script not yet, because I don’t know how to do it. Here’s the link http://pastebin.com/NVPUnEub
– Raank