Skip to content

Instantly share code, notes, and snippets.

@namusyaka
Created April 3, 2011 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save namusyaka/900443 to your computer and use it in GitHub Desktop.
Save namusyaka/900443 to your computer and use it in GitHub Desktop.
function addPropertyToElement(element, property) { //property format is object . {'foo' : 'bar'}
for(var i in property)
element.style[i] = property[i];
}
onload = function() {
addPropertyToElement(document.getElementsByTagName('h1')[0], {
'color' : 'red',
'fontSize' : '50px',
'border' : '1px solid black',
'padding' : '10px'
})
}
<html>
<head>
<title>test</title>
</head>
<body>
<h1>test/h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment