So, my question in it’s most basic form:
<div id="total"> 0 </div>
and what I’m hoping to accomplish with jQuery:
$(document).ready(function() {
if ("#total" > 2){
/*do something*/
}
});
I feel like this should be something relatively easy, but the syntax is escaping me. Any help would be extremely helpful. Thanks!
Rob
You can use the
textmethod to get the text of an element, andparseIntto get a Number from that:Here’s a working example.
Note how the selector (
#total) is passed into jQuery ($(selector)). In your question you have the correct selector, but it’s just a string, so yourifstatement would compare the string “#total” to the number 2.