473,508 Members | 2,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Any way to achieve this using only stylesheets (no Javascript)?

I have a line of text for which I want each word to become highlighted
(change background color) when the mouse cursor hovers over it, but
with one catch: when hovering over a word, it should highlight not only
itself but also every word following it until the end of the sentence.
So far, I have only been able to do this through Javascript onMouseOver
and onMouseOut events, identifying each word by an 'id' attribute and
changing its background color accordingly. All this makes the HTML
quite lengthy, and I was wondering if there would be a cleaner way to
do this using only CSS?
Thanks

Jan 5 '07 #1
1 1332

da********@gmail.com wrote:
So far, I have only been able to do this through Javascript onMouseOver
and onMouseOut events,
Sounds reasonable to me. I don't think CSS would ever be able to do
this and JS is a perfectly reasonable solution.
identifying each word by an 'id' attribute
Sounds like you need some smarter JS. Don't pass an element's id into
your event handler, use the JS event object that already exists and
represents the source of the event. From this you should be able to
access the DOM and traverse it as needed, without needing to set
explicit ids in the HTML.

Jan 5 '07 #2

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

Similar topics

2
2112
by: fad | last post by:
How can I create a database access using asp+javascript withen the code?Is there (createdatabase)?If yes how can we use it? thanks for all -- fad...
1
2389
by: ritskits | last post by:
I have the dropdownlist that is populated when the form is loaded. I have the button that opens search child window using the modalwindowdialog and it returns the value that I want to add to the...
2
1021
by: Iams | last post by:
How do I set up in a style sheet what format I want to use for various controls, such as a drop down list? The format is not following the body font, nor tables (which the ddl's are in), nor even...
1
12744
by: bill | last post by:
I need to be able to dynamically add items to a <asp:listbox> (or HTML <select runat=server>) using clientside javascript, and retrieve the items when the page is posted back. I use this code to...
17
121565
by: kartheek | last post by:
hi friends, can any one out here help me by giving me the code to connect to an MSACCESS database using javascript.
3
3443
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
5
3642
by: lilOlMe | last post by:
I have an extern JavaScript file I've called "Utils.js". It will eventually hold all of the common JavaScript functions used throughout the ASPX pages that make up my website. Right now this file...
3
5760
by: farukcse | last post by:
Hi, Can any one tell me how to assign a php variable value using ajax / javascript? Regards, Faruk Chowdhury
6
4936
by: kiranbabu | last post by:
how to rotate an image using html/javascript
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
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
7323
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,...
1
7039
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
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.