set variable to function value in jQuery? -


im attempting set variable function, , set variable's value function's output, can't put finger on how grab output correctly:

var prev = activesection.prevall();  var = prev.each(function(){       $(this).data('about'); }) 

now .data func's value value want set about var to, when log about var, elements of prev var, not .data('about') of each of them, desire.

i know i'm off minute... suggestions?

the jquery .each function using iterates on elements. you're not adding them list, nothing happening value.

you modify existing code follows add values array:

var prev = activesection.prevall();  var = []; prev.each(function(){       about.push($(this).data('about')); }); 

alternatively, can use jquery map adeneo noted, or can in non-jquery foreach loop.

var prev = activesection.prevall();  var = []; prev.foreach(function() {   var val = $(this).data('about');   about.push(val); }); 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -