jQuery If value is NaN

You have to assign the value back to $(this):

$('input').keyup(function() {

var tal = $(this).val();
var num = $(this).data('boks');
if(isNaN(tal)) {
var tal = 0;
}
$(this).data('boks', tal);
});

nicely written:

$('input').keyup(function() {
    var eThis = $(this);
    var eVal = (isNaN(eThis.val())) ? 0 : eThis.val();
    eThis.data('boks', eVal);
});

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)