1:var counter = 1; 2:addChangesListener(changeElStyle) 3: 4:function add(type) { 5: var ed = document.getElementById("ed"); 6: var els = document.getElementById("els"); 7: var el, op; 8: 9: clearStyle(); 10: 11: el = document.createElement(type); 12: el.innerText = type + "_" + counter; 13: el.id = type + "_" + counter; 14: 15: op = document.createElement("option"); 16: op.value = el.id; 17: op.innerText = el.id; 18: els.appendChild(op); 19: ed.appendChild(el); 20: counter++; 21:} 22: 23:function changeElStyle() { 24: var els = document.getElementById("els"); 25: var elid = els.value; 26: 27: if (elid == "") { 28: return; 29: } 30: 31: var el = document.getElementById(elid); 32: 33: var values = getStyle(); 34: for (var i = 0; i < values.length; i++) { 35: var splitted = values[i].split("="); 36: 37: var key = splitted[0]; 38: var dash = key.indexOf("-"); 39: while (dash > -1) { 40: key = key.substring(0, dash) + key.substring(dash + 1, dash + 2).toUpperCase() + key.substring(dash + 2); 41: dash = key.indexOf("-"); 42: } 43: 44: el.style[key] = splitted[1]; 45: } 46:} 47: