Hello,
I am trying to change the font style of var element to match the font style of whatever i am inserting the var element into. This element could be a header, list item, paragraph or eny other kind of element. Any help in doing this would be appreciated because all I get when I try to access the parent element is undefined or null.
function setVarStyle(){
var varcopy = document.getElementsByTagName("var");
var varparent;
if (varcopy.length < 1) return false;
for (var i = 0; i < varcopy.length; i++){
varcopy[i].css{font-style:inherit};
}
}
function setVarStyle(){
var varcopy = document.getElementsByTagName("var");
var varparent;
if (varcopy.length < 1) return false;
for (var i = 0; i < varcopy.length; i++){ varcopy[i].css{font-style:inherit}; }
}
bolded line should read
varcopy[i].style.fontStyle = "inherit";
__________________
-Mike
"Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender
function setVarStyle(tgnm){
var varcopy = document.getElementsByTagName(tgnm);
if (varcopy.length < 1) return false;
for (var i = 0; i < varcopy.length; i++){
varcopy[i].style.fontStyle = varcopy[i].parentElement?varcopy[i].parentElement.style.fontStyle:"normal";
}
}
pass in the name of the tag to the function, ie
setVarStyle("div");
__________________
-Mike
"Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender
Apparently the var element is italicized by default and what my supervisor wants me to do is set the font attributes based on what the parent has. With doing nothing, the var element inherits everything from the parent but the font-style. I can set the font-style by hard coding it but I am having problems accessing the font-style property of the parent.