Click to See Complete Forum and Search --> : styles / css question
mitya
12-03-2003, 01:17 PM
Hi all
I know you can change an element's border colour with document.all.elementid.style.borderColor = 'colour', but is it possible to affect just one particular border? I.E top or bottom, not all?
Also, is it possible for javascript to change the properties of a CSS style on the page? I'm working on an app where the user can choose colours, but some colours are goverened by CSS. When they select a certain colour I'd like all relevant colours to update.
Thanks in advance.
zachzach
12-24-2003, 11:37 AM
first of all, instead of "documant.all.id.whatever", just "id.whatever" will work.
umm...yes...its complicated and i do not know the tecnical details...MicroSoft FrontPage has a stlye propertie for tables that let you use the program to do it...frontpage makes it easy in other words
fredmv
12-24-2003, 12:00 PM
Originally posted by zachzach
first of all, instead of "documant.all.id.whatever", just "id.whatever" will work.Incorrect. Under IE and IE only will using that work correctly since IE pollutes the global namespace will all elements given an id attribute. The more correct, standardized, cross-browser way is using the document.getElementById DOM method. As for the original question, it can be done by altering the border-top|right|bottom|left-color CSS property. For example:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>untitled</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" />
</head>
<body>
<div>
<a href="#" style="padding: 5px; border: solid #000 1px;" onclick="style.borderTopColor = '#f00';">foo</a>
</div>
</body>
</html>
ray326
12-24-2003, 12:04 PM
I'm sorry to say I haven't verified this but I read it here so it must be so. In a style where you would use, e.g., border-top the corresonding DOM access would be xxx.style.borderTop. You need to find a replacement for document.all, though, because that's IE-specific. Normally I believe document.getElementById("foo") is used.