javascript - Raphael setting the attr of an element -


i using raphaeljs add need set attributes on element, attributes name , value saved in variables

var attr_name='fill';  var attr_value='#343434'; 

but following not work

exampleelement.attr({attr_name: attr_value}); 

however if type in actual name in attr field works

exampleelement.attr({'fill': attr_value});  

i have tried wrapping in quotes , double quotes has no effect.

please can suggest anything? not option manually type them in code runs in loop , each time different attribute setting.

try -

exampleelement.attr(attr_name, attr_value); 

jquery docs - .attr()


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -