When someone clicks the +/- button on my calculator, it should add a negative sign if the number is positive, and take away the negative sign if the number is negative.
It seems like a simple task to write a function for this, but it’s not working. I’m using jQuery.
I’ll just post the relevant parts of my code.
Under HTML, I have:
<input type="text" name="output" id="output">
<input type="button" name="opp" value="+/-" id="opp" onclick="opposite()"/>
Under JS, I have:
$("#opp").click(function(opposite){
var b=document.getElementById("output");
var n=b.value;
n = n * -1;
});
How can I get this working?
Thanks!