Suppose I have button like this:
<button>÷</button>
I want to use switch operator with string variable.
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("button").click(function(){
var value=$(this).text();
console.log(value);
switch(value){
case "÷":
alert("OK");
break;
case "÷":
alert("OK");
break;
}
});
}
);
</script>
</head>
<body>
<button>÷</button>
</body>
</html>
But none of those alerts appear on button click.console.log() shows:
"÷"
My browser - firefox 39.0.