Forum Moderators: open
function change(id, newClass)
{
if (document.getElementById(id)) {document.getElementById(id).className=newClass;}
else if (id) {id.className=newClass;}
else {alert('Error: the id \''+id+'\' was not found or has not yet been imported to the DOM.\n\nNew class intended: '+newClass);
}
}
// usage
change('page_inner','block');
//CSS
//.block {display: block;}
function setstylebyid(i,p,v)
{
if (document.getElementById(i))
{
var n = document.getElementById(i);
if (n != null) {n.style[p] = v;}
}
else {alert('Error: the id \''+i+'\' was not found or has not yet been imported to the DOM.\n\nNew property intended: '+p+'\n\nNew value intended: '+v);
}
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<style>
#page {
background-color: #777;
height: 400px;
width: 400px;
display: inline;
}
#page_inner {
background-color: #00ff00;
margin: 30px auto;
height: 300px;
width: 300px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#page #page_inner").parent().css('display' , 'block');
});
</script>
</head>
<body>
<div id="page">
my outer div
<div id="page_inner">
my inner div
</div>
</div>
</body>
</html>