473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

setting the style of a child object

i use document.getelementbyid('id').style.colour= a lot anyone know how to
set the style of the link in the following code

<li id="tab1"><a href="#">moo</a></li>

because setting the colour of tab1 doesnt work.

Mark
Jul 23 '05 #1
5 1878
mark | r wrote on 24 jan 2005 in comp.lang.javascript:
i use document.getelementbyid('id').style.colour= a
Mind the case sensitivity
lot anyone know
how to set the style of the link in the following code

<li id="tab1"><a href="#">moo</a></li>

because setting the colour of tab1 doesnt work.


<style>
.coloured {color:red;}
.coloured a {color:green;}
</style>

<li><div id="d">Hello <a href="#">World</a></div>

<script>
document.getElementById('d').className= "coloured"
</script>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2
mark | r wrote:
i use document.getelementbyid('id').style.colour= a lot anyone know how to
set the style of the link in the following code

<li id="tab1"><a href="#">moo</a></li>

because setting the colour of tab1 doesnt work.
Because setting the colour of tabl *does* work, but "moo" is inside an
'a' tag that will not change when you modify the 'li' tag.

Borrowing from Evertjan:

<html><head><title>play</title></head>
<body>

<li><div id="d" onclick="makeMeRed();">Hello <a
href="#">World</a></div>

<script type="text/javascript">
function makeMeRed() {
document.getElementById('d').style.color = 'red';
}
</script>

</body></html>

Mark

Jul 23 '05 #3

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
mark | r wrote on 24 jan 2005 in comp.lang.javascript:
i use document.getelementbyid('id').style.colour= a


Mind the case sensitivity
lot anyone know
how to set the style of the link in the following code

<li id="tab1"><a href="#">moo</a></li>

because setting the colour of tab1 doesnt work.


<style>
.coloured {color:red;}
.coloured a {color:green;}
</style>

<li><div id="d">Hello <a href="#">World</a></div>

<script>
document.getElementById('d').className= "coloured"
</script>


no, wait, i get it, it dynamically sets a class for the div containing an
ID - how do you set this to none?

mark
Jul 23 '05 #4
On Mon, 24 Jan 2005 11:23:00 -0000, mark | r <ma******@gmail.com> wrote:
i use document.getelementbyid('id').style.colour= a lot anyone
know how to set the style of the link in the following code

<li id="tab1"><a href="#">moo</a></li>

because setting the colour of tab1 doesnt work.


In theory it should, however user agents tend to treat link colours
specially.

If there's no whitespace between the start tags for the list item and
anchor elements, you could use

document.getElementById('tab1').firstChild.style.c olor = ...;

adding appropriate feature detection, of course.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #5
mark | r wrote on 24 jan 2005 in comp.lang.javascript:
<script>
document.getElementById('d').className= "coloured"
</script>


no, wait, i get it, it dynamically sets a class for the div containing an
ID - how do you set this to none?


Elementary, my dear Watson:

document.getElementById('d').className= ""

[I had to test it, perhaps amazingly and it works]
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Carlos Ribeiro | last post by:
Hello all, Here I am using some deeply nested, tree-like data structures. In some situations I need to traverse the tree; the old-style way to do it is to write a recursive method on the node...
3
by: Greg Copeland | last post by:
Okay, I have: class Base( object ): def __init__( self ): self._attrib = "base" print "Base" def real( self ): print "Base.real() is calling base.virtual()" self.virtual()
20
by: Arne | last post by:
During testing <div style="overflow:auto;"> in CSS I noticed the mousewheel would work in Mozilla only after I made a <a href="#">some text</a> link and clicked on that, within the div. It...
10
by: p3t3r | last post by:
I have a treeview sourced from a SiteMap. I want to use 2 different CSS styles for the root level nodes. The topmost root node should not have a top border, all the other root nodes should have a...
12
by: Mark Rae | last post by:
Hi, It's easy enough for a child page to manipulate its MasterPage's header simply by modifying the MasterPage thus: <header runat="server"> .... .... </header>
6
by: mmcloughlin | last post by:
I'm learning about objects and am trying to figure out how basic inheritance works. I've got into the habit of explicitly setting the prototype object with an object literal as it seems to make the...
6
by: rongchaua | last post by:
Hi all, I want to change the style of a button. But I don't know how to do it. For example, I have already a button OK on form. I want to add these styles to this button (WS_CHILD || WS_VISIBLE ||...
1
by: whitelined | last post by:
Does Opera have problems setting cursor style? I have the following code that works in FF & IE: this.pane.style.cursor = 'ne-resize'; It kind of works in opera, but seems to be variable to say...
1
by: Blau | last post by:
I'm still trying to learn c#, and while doing so I am trying to convert some C++ code to C#. Doing so has kind of challenged my understanding of the way values and references work in C# when i'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.