Aurelijus1 Aurelijus1 - 2 months ago 5x
HTML Question

How to define value in javascript

I tried to use $(".input-text").val() to define value but all code stop working, maybe there is other way that i can define it from input text? Here is that line:

var oMain = new CMain({
howmuch: $(".input-text").val()

Only works if i put number instead of $(".input-text").val()


$(".input-text").val() returns string, so if CMain expects integer in howmuch you need to convert value to integer:

howmuch: parseInt($(".input-text").val())