How To Check Value Of String

73 Views Asked by At
<span id='amount'>0.00000000</span>
<a class='button-withdraw' id='tombolco' href='#'>Checkout</a>

<script>
    var amount = document.getElementById("amount").innerHTML;
    if (amount >= 0.001) {
        document.GetElementById("tombolco").style = "display:block";
    } else {
        document.GetElementById("tombolco").style = "display:none";
    }
</script>

Why doesn't my code work? What's wrong with it and how can I solve it?

3

There are 3 best solutions below

0
On BEST ANSWER
document.GetElementById("tombolco").style = "display:block";

That's not the right way. This is

document.getElementById("tombolco").style.display = 'block';

Also note that it is getElementById, not with a capital G. Same with 'none',Rest of your code is fine.

Fiddle

0
On

If you want to assign a CSS string to the element, as you are trying to do, use style.cssText:

document.getElementById("tombolco").style.cssText = "display:block";
0
On
<script>
var amount = document.getElementById("amount").innerHTML;
if (amount >= 0.001) {
document.getElementById("tombolco").style.display = 'block';
} else {
document.getElementById("tombolco").style.display = 'none;
}
</script>