Why am I getting ‘undefined’ in console? [duplicate]

A for…in loop in JavaScript loops through an object’s keys, not its values. You can use Array.prototype.forEach, given support; $.each works as a fallback too, since you’re using jQuery.

var textArray = ['#text1', '#text2', '#text3', '#text4',
                 '#text5', '#text6', '#text7', '#text8'];

$('#capture').click(function() {
    textArray.forEach(function (x) {
        console.log($(x).offset());
    });
});

Leave a Comment

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