ParseInt is used for data type conversion of jquery in js numerical calculation

  • 2020-03-30 04:02:33
  • OfStack

By default, the data obtained by js is of the type of string string. If the operation of numeric value is carried out, the operation of converting to numeric value must be carried out by using parseInt.

HTML code:


<div id="archive">
    <input type="hidden" name="page" value="1" />
</div>

Js code:


$("#archive").bind('click',function(){
      
    var page=$("input[name='page']").val();
    //To use parseInt for the numeric operation
    $("input[name='page']").val(parseInt(page)+1);    });


Related articles: