473,854 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

change CSS definition by javascript

Hi,

i have a basic question on CSS.
Is it possible to change the CSS class definition dynamically by using
Javascript.

example:
ich have a css class like this one:

..test {
color: red;
}

and some HTML tags like

<span class="test">bl a bla</span>
...
<span class="test">bl a bla</span>
...
<span class="test">bl a bla</span>

and now ic would have a link/button to click and then change the color
attribute in class test to blue with Javascript (means without reloading
page and changing it on the server)

is that possible?

thanks.

gerhard
Jul 21 '05 #1
8 64366
Gerhard Hönig wrote:
i have a basic question on CSS.
Is it possible to change the CSS class definition dynamically by using
Javascript.

example:
ich have a css class like this one:

.test {
color: red;
}

and now ic would have a link/button to click and then change the color
attribute in class test to blue with Javascript (means without reloading
page and changing it on the server)

is that possible?


Yes. <http://homepages.tesco .net/~J.deBoynePolla rd/FGA/questions-with-yes-or-no-answers.html>

--
Steve

Any sufficiently advanced technology is indistinguishab le from magic.
-Arthur C Clarke
Jul 21 '05 #2
On Fri, 13 May 2005 08:02:49 -0400, in
comp.infosystem s.www.authoring.stylesheets , "Steve Fulton"
<ce********@gee mail.com> in <op.sqpqej1ii0i x9l@steve> wrote:
Gerhard Hönig wrote:
i have a basic question on CSS.
Is it possible to change the CSS class definition dynamically by using
Javascript.

example:
ich have a css class like this one:

.test {
color: red;
}

and now ic would have a link/button to click and then change the color
attribute in class test to blue with Javascript (means without reloading
page and changing it on the server)

is that possible?


Yes. <http://homepages.tesco .net/~J.deBoynePolla rd/FGA/questions-with-yes-or-no-answers.html>


I am not the OP, but thanks for this link. It should come in two
versions, though. One with a big "YES" and one with a big "NO". Then
you could give one or the other link as the answer.
--
Matt Silberstein

All in all, if I could be any animal, I would want to be
a duck or a goose. They can fly, walk, and swim. Plus,
there there is a certain satisfaction knowing that at the
end of your life you will taste good with an orange sauce
or, in the case of a goose, a chestnut stuffing.
Jul 21 '05 #3
Yes

http://www.dannyg.com/pubs/index.html


"Steve Fulton" <ce********@gee mail.com> a écrit dans le message de news:
op.sqpqej1ii0ix 9l@steve...
| Gerhard Hönig wrote:
|
| > i have a basic question on CSS.
| > Is it possible to change the CSS class definition dynamically by using
| > Javascript.
| >
| > example:
| > ich have a css class like this one:
| >
| > .test {
| > color: red;
| > }
| >
| > and now ic would have a link/button to click and then change the color
| > attribute in class test to blue with Javascript (means without reloading
| > page and changing it on the server)
| >
| > is that possible?
|
| Yes.
<http://homepages.tesco .net/~J.deBoynePolla rd/FGA/questions-with-yes-or-no-answers.html>
|
| --
| Steve
|
| Any sufficiently advanced technology is indistinguishab le from magic.
| -Arthur C Clarke
Jul 21 '05 #4
Matt Silberstein wrote:
<ce********@gee mail.com> in <op.sqpqej1ii0i x9l@steve> wrote:
Gerhard Hönig wrote:
[snip some CSS question]
is that possible?
Yes.

<http://homepages.tesco .net/~J.deBoynePolla rd/FGA/questions-with-yes-or-no-answers.html>
I am not the OP, but thanks for this link.
I doubt the OP will be thanking anyone...
It should come in two
versions, though. One with a big "YES" and one with a big "NO". Then
you could give one or the other link as the answer.


Isn't this more than a little evil? Implicit questions are a major
feature of English (at least in Britain - maybe everyone else is more
direct?) and we'd never get anywhere if people insisted on taking
everything literally...

--
Safalra (Stephen Morley)
http://www.safalra.com/science/linguistics/

Jul 21 '05 #5
Gerhard Hönig wrote:
i have a basic question on CSS.
Is it possible to change the CSS class definition dynamically by using Javascript.


See:

http://www.faqts.com/knowledge_base/...d/2147/fid/128

--
Safalra (Stephen Morley)
http://www.safalra.com/hypertext/

Jul 21 '05 #6

"Steve Fulton" <ce********@gee mail.com> wrote in message
news:op.sqpqej1 ii0ix9l@steve.. .
Gerhard Hönig wrote:
i have a basic question on CSS.
Is it possible to change the CSS class definition dynamically by using
Javascript.

example:
ich have a css class like this one:

.test {
color: red;
}

and now ic would have a link/button to click and then change the color
attribute in class test to blue with Javascript (means without reloading
page and changing it on the server)

is that possible?
Yes.

<http://homepages.tesco.net/~J.deBoyn...th-yes-or-no-a
nswers.html>
--
Steve

Any sufficiently advanced technology is indistinguishab le from magic.
-Arthur C Clarke


Hi Steve,

thanks lot for this little lesson in english semantics
I'll try to remember ist when perhaps I will find any of yours questions
:-))

gerhard
/o
Jul 21 '05 #7
Gerhard Hönig wrote:
Hi,

i have a basic question on CSS.
Is it possible to change the CSS class definition dynamically by using
Javascript.

and now ic would have a link/button to click and then change the color
attribute in class test to blue with Javascript (means without reloading
page and changing it on the server)


See the discussion on "Alternate style sheets" 4/24/05.
You may be interested in my link of an example/demo.
I used onmouseover but onclick may be used if desired.

--
Gus

Jul 21 '05 #8
A solution is here:

http://www.projectseven.com/extensio...lass/index.htm

Great if you use Dreamweaver, very useable, but a little more work if
you dont.

Jul 21 '05 #9

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

Similar topics

2
7646
by: Christian Kusenbach | last post by:
Hello group! I've a problem with JavaScript and IMG-Objects. On my webpage I use a big image and several small images. If you click on a small image, it executes a JavaScript to change the source of the big image to the source of the small image. It's working fine, but on some browsers (I use IE 6.0.2800.1106) the image doesn't change properly. I click on the image and the big image turns white. Now I have to
12
6861
by: techie | last post by:
Hi All, I have a portal working on an intranet for a company. The portal was designed keeping in mind the resolution of 1024*768. I am including a ..css file in all the files. Now i have to make the file compatible for both 1024*768 and 800*600 resolutions. I don't want to change all the files to include an alternate css. Can i write some javascript conditions in the css files to change the class definitions based on resolutions. I am not...
3
9847
by: Catherine Lynn Smith | last post by:
I am creating a webpage with dhtml <DIV> layers and I want a link on one layer to modify the content on another but I seem to keep running into errors. Basically I create a layer in the middle of the screen that initially comes up with a gif image of a house: <!-- start "house" layer definition for center of screen --> <DIV id="house" style="position:absolute; left:140px; top:137px; width:510px; height:325px; z-index:2"><img...
9
2294
by: Nick | last post by:
I have the following code, and it works well on Mozilla 1.6. (However, the image src property cannot be set on Mozilla 1.2.1). Unfortunately, all the code: document.images.itemImage.src = itemInfo.imageUrl; //document.getElementById("itemImage").src = itemInfo.imageUrl; document.getElementById("descr").innerHTML = itemInfo.descr; document.getElementById("price").innerHTML = itemInfo.price; doesn't work on IE. What's the proper way to...
0
3565
by: Jimmy Cerra | last post by:
I recently came up with a cool little stylesheet for definition lists. There is a small demostration for the impatient . I hope this helps someone. Here's how I did it. Definition lists are usually styled something like: ] Term ] A tab of white space followed by the definition ] By
2
6189
by: Pete Kipe | last post by:
I'm not a JavaScript programmer...but I'm trying to put together a simple menu system for a new website and need a little help. I have the following script: <SCRIPT language=javascript> <!-- Hide JavaScript from Java-Impaired Browsers function NavRollOver(oTd) {if (!oTd.contains(event.fromElement)) {oTd.bgColor="#CC0000";}} function NavRollOut(oTd) {if (!oTd.contains(event.toElement))
3
8130
by: Gerhard Hönig | last post by:
Hi, i have a basic question on CSS. Is it possible to change the CSS class definition dynamically by using Javascript. example: ich have a css class like this one: ..test {
3
1881
dmjpro
by: dmjpro | last post by:
Today i encountered a typical thing. So far what i knew that JavaScript had a scope inside a function but it was not there. I think in newer version of JavaScript it is introduced, in older version there may be. Anyway ..... Have a look at my code snippet .... function test(){ var s = "Hello!"; var s = "Hi!"; alert(s); //it alerts the latest value of s, and here is no duplicate definition of s }
15
3745
by: Sunny | last post by:
Hi, I can change the lement opacity in IE using. abc.style.filter = 'alpha(opacity=' + 10 + ')'; But this dont work in firefox, In firefox it throws error. How I can change the opacity of an element in Firefox.
0
9901
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10678
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10751
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10367
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9512
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7914
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4557
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 we have to send another system
2
4153
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3185
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.