I have an function that creates an array of html buttons:
function getButtons() { // buttons that participants see in the selection phase.
var trialButtons = [
'<button class="jspsych-btn" style="color:blue; font-size: 20px; background-color:#CD6155; border-width: 2px; position:absolute; left: 120px; top:20px; width:210px; height:170px" >%choice%</button>',
'<button class="jspsych-btn" style="color:blue; font-size: 20px; background-color:#D7BDE2; border-width: 2px; position:absolute; left: 120px; top:220px; width:210px; height:170px" >%choice%</button>',
'<button class="jspsych-btn" style="color:blue; font-size: 20px; background-color:green; border-width: 2px; position:absolute; left: 120px; top:420px; width:210px; height:170px" >%choice%</button>',
'<button class="jspsych-btn" style="color:blue; font-size: 20px; background-color:#F4D03F; border-width: 2px; position:absolute; right:120px; top:20px; width:210px; height:170px" >%choice%</button>',
'<button class="jspsych-btn" style="color:blue; font-size: 20px; background-color:#DC7633; border-width: 2px; position:absolute; right:120px; top:220px; width:210px; height:170px" >%choice%</button>',
'<button class="jspsych-btn" style="color:blue; font-size: 20px; background-color:#BDC3C7; border-width: 2px; position:absolute; right:120px; top:420px; width:210px; height:170px" >%choice%</button>',
'<button class="jspsych-btn jspsych-btn_instructions" style="position:absolute; left:180px; bottom:30px;" >%choice%</button>'
];
myButtons = [];
myButtons.push(trialButtons);
return myButtons[myButtons.length -1];
}
How can I manipulate my array to change the style of all the buttons? For example how could I change all the buttons to have border-color:red?
[{class: 'www', btn_name: 'My button', style: {color: 'blue'}}]etc? Anything short of that would require some regex to search and replace string patterns.