I\'m new in javascript and i don\'t exactly understand how to modify this code to style a div:
function getParameters() {
var searchString = document.getElemen
the variables in the .each(function(){});
function are not custom, they are always id and value.
your function should go like this:
$.each(hash, function (id, value) {
test_div.style[id] = value;
});
here is a FIDDLE
whats going on basically is, that your hash array contains two objects:
1) color {value = "red"}
2) background {value = "yellow}
the each function iterates thought those, the id
will be first time color
ad second time background
and the value will be first time "red"
ad second time "yellow"
so for the first iteration for example, id = 'color' and value ='red' and it will produce:
test_div.style["color"] = "red";