div-specific css merging

D

drblitzkrieg

Hi, I'm wondering if this is possible:

Can you assign a different CSS file to each DIV in your document, and
then with JavaScript dynamically change it out? An example would be
appreciated.
 
D

David Mark

(e-mail address removed) said the following on 12/6/2007 7:14 AM:



No. But, why would you want to? Assign each DIV element a class and
change its className property.


document.getElementById('myDiv').style.className = "newClass";

Should be:

document.getElementById('myDiv').className = "newClass";
 
T

Thomas 'PointedEars' Lahn

David said:
Should be:

document.getElementById('myDiv').className = "newClass";

Should be:

/** @see http://PointedEars.de/scripts/types.js */
function isMethodType(s)
{
return /\b(function|object)\b/i.test(s);
}

var o;
if (isMethodType(typeof document.getElementById)
&& document.getElementById
&& (o = document.getElementById('myDiv'))
&& typeof o.className != "undefined")
{
o.className = "newClass";
}


PointedEars
 
T

Thomas 'PointedEars' Lahn

Randy said:
Thomas 'PointedEars' Lahn said the following on 12/6/2007 4:32 PM:

No it shouldn't.

Yes, it should, as that is the most reliable and most compatible way
conceived for a feature test of a DOM method so far. You will find that
confirmed if you read the discussions you are referring to below more
thoroughly.
Since it has already been shown to you that your function can return
incorrect results, anything based on that code is suspect.

It has merely been shown that the function can return incorrect
results if applied in the wrong way. As that is the case with
any code. Stop trolling.


PointedEars
 
D

David Mark

On Dec 10, 5:24 pm, Thomas 'PointedEars' Lahn <[email protected]>
wrote:

[snip]
It has merely been shown that the function can return incorrect
results if applied in the wrong way. As that is the case with
any code. Stop trolling.

I have to ask. After all of the carping you did about the issue of
passing unqualified references, how do you justify these?

function isDefined(a)
{
return (typeof a != "undefined");
}

function isUndefined(a)
{
return (typeof a == "undefined");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top