This seems so simply yet its not working (undefined).
I have set a var to <ul> which is a child of <div> element “feature_tabs_indicators”.
The pBoxShadowProperty function gets the BoxShadow property supported by the current browser.
And the final statement merely sets the pBoxShadowProperty to 0, i.e. its overriding the CSS set Box-Shadow property.
Can someone please explain what I am doing wrong here in the last statement?
Best,
var iActiveNo = 0;
var eTabInd = document.getElementById ("feature_tabs_indicators").children[0];
var pBoxShadowProperty = getSupportedCSSproperty(["boxShadow", "mozBoxShadow", "webkitBoxShadow"]);
function getSupportedCSSproperty (propertyArray)
{
var root = document.documentElement;
for (var i = 0; i < propertyArray.length; i++)
{
if (typeof root.style[propertyArray[i]] === "string")
{
return propertyArray[i];
}
}
}
iActiveNo = iActiveNo + 1;
eTabInd.children[iActiveNo - 1].style[pBoxShadowProperty] = "";
Here is the jsfiddle, press the light green button ‘rght’ on top right.
I think I figured out what your issue is. You use here:
something that has not been defined in your posted code. However you do have:
which I think should have actually been:
otherwise your code has JS error in it (as it is posted, anyway).
Other than that (that is, if your intention was to take the 1st
<li>element out of the<ul>element and remove itsbox-shadowCSS property) – your code is just fine.Edit
Dude, what a mess.. 🙂 Here is a JSFiddle I fixed up a bit. Below is the explanation.
There are several things going on in that JSFiddle that should be fixed before we get to the real problem.
You have errors in that fiddle – see console. The line:
doesn’t end with a semicolon, and is then interpreted as a function due to (..) on the next line (I think) – which (for me at least) results in an error in JS console. If semicolon is added – error is gone.
Additionally… There is a line:
console.log (eTabInd.children[iActiveNo-1].style.pBoxShadowProperty);which prints your
undefinedand is exactly what was discussed below and should bewhich then prints the empty string.
Moreover, when printed, your
pBoxShadowPropertyvariable containsboxShadowstring. Which is, of course, not a valid CSS property I am familiar with. So this:won’t do a thing.
Now to the meat of the issue here…
doesn’t have ‘box-shadow’ property to begin with, because you haven’t put it in
styleattribute of<li>element. It is put on the<li>element through the virtues of this CSS selectors sequence:#feature_tabs_indicators ul #ind_bt.Now, since you wanted the
styleattribute – you won’t get the computed style the above CSS selectors sequence applies. Thus – you won’t be able to remove it.What you could have done is create another class, that doesn’t have a
box-shadowproperty and replace your originalc_indwith it.