I have a problem with my condition:
Uncaught TypeError: Cannot read property 'length' of undefined
It is logic, but how can i fix this?
Thank you.
<script>
$(window).scroll(function () {
var elementms = $("#testms").attr("john");
if (elementms.length) {
$({
someValue: 0
}).animate({
someValue: 500
}, {
duration: 3000,
easing: 'swing', // can be anything
step: function () { // called on every step
// Update the element's text with rounded-up value:
jQuery('#el').text(commaSeparateNumber(Math.round(this.someValue)));
}
});
function commaSeparateNumber(val) {
while (/(\d+)(\d{3})/.test(val.toString())) {
val = val.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
}
return val;
}
}
});
</script>