jquery - Show 0 instead of NaN on my website -


hi when value nothing displays nan i want show 0.

here code:

<script> var xtruncated = 0;  $(".slider2, .slider").slider({   change: function(event, ui) {     $(".slider2").data('prodprijs2', ui.value);     $(".slider").data('bierprijs2', ui.value);     var x = ($('.slider2').slider('value') / $('.slider').slider('value'));     var xtruncated = math.round(x).tofixed(0);     var uitslag = xtruncated;      $('#bier').text(xtruncated);   } }); </script> 

check isnan

var xtruncated = (isnan(x) ? 0 : math.round(x).tofixed(0)); 

documentation: https://www.w3schools.com/jsref/jsref_isnan.asp

hope you.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -