I have this very simple calculator that I wrote in JavaScript. Basically, it works profitably between two integers with a tax amount of 5%.
I would like the result ( #result ) to change color depending on whether the number of results is a positive or negative integer.
Here is my HTML calculator:
Buying Price <br /><br /> <input id="buying" type="text"> <br /><br /> Selling Price <br /><br /> <input id="selling" type="text"> <br /><br /> <input type="submit" onclick="output();"> <p id="result" name="r1"></p>
Here is my JS calculator:
function output(){ var buying = document.getElementById('buying').value; var selling = document.getElementById('selling').value; parseInt(selling) / 20; document.getElementById('result').innerHTML = parseInt(selling) - parseInt(buying) - parseInt(selling) / 20; }
Here is the JS fiddle: http://jsfiddle.net/ac81ee78/
I tried using jQuery for this, but it did not work.
Please, if anyone can help me with this, we will be very grateful.
source share