I've been working on creating an SVG map of the US, and I'm almost finished. The final step involves implementing a simple if-else statement to prompt users for the name of the state when they click on it. My goal is to fill the state green if the input in the prompt is correct, and red if incorrect. Currently, the code fills the state red every time, even when the input is accurate. How can I resolve this issue quickly? Your assistance by today would be greatly appreciated. You can view the jsfiddle here: https://jsfiddle.net/vnqcyu90/
jQuery(function($) {
$('path').click(function() {
prompt("Enter State Initials")
if ($('path id') == prompt) {
this.style.fill = "green";
} else {
this.style.fill = "red";
}
});
});
This particular line of code is causing me trouble, as it both adds the onclick function to the SVG map and handles the if-else statement related to the prompt asking for the state's name (which, in my case, matches the path id). (This code is jQuery 1.7.1)