javascript - Can anyone explain why array.length would return two different results here? -
javascript - Can anyone explain why array.length would return two different results here? -
can please @ this:
(function ($) { $.fn.extend({ grid: function (settings) { var defaults = { data: [ ['code','name','email','other'], [1,'john','john@domain.com','johny'], [2,'bob','bob@domain.com','bobby'], [3,'jenny','jenny@domain.com','jen'], [4,'mary','mary@domain.com','maryann'] ], test: this.data.length }; var config = $.extend(defaults, settings); homecoming this.each(function(){ this.innerhtml = config.data.length; this.innerhtml += "<br />" + config.test; }); } }); }(jquery)); $('.content').grid();
http://jsfiddle.net/w8pg6/
and explain why 2 results different?
also how accomplish desired result?
the problem when phone call this.data.length
, it's counting length of jquery data
function , not length of defaults
. additionally, can't count length of defaults.data
until after it's been assigned.
have @ working example: http://jsfiddle.net/w8pg6/1/
javascript jquery
Comments
Post a Comment