473,385 Members | 1,927 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,385 software developers and data experts.

Change a css background

Hello all,

I have used javascript a little bit (along time ago) so my knowledge is pretty limited (very limited).
I am trying to figure out a way that I can change a css background when a certain tag is on a page..

I.e
The background image is a picture of a bird because a tag on the page says "bird"

The tag on the next page says "dogs", so there is a picture of some dogs..

there would probably be about 7-8 different tags and images

Is this hard to do ?

Expand|Select|Wrap|Line Numbers
  1. .bird{
  2.     background: url(images/bird.png) left top no-repeat;
  3. }
  4. .dog{
  5.     background: url(images/bird.png) left top no-repeat;
  6. }
  7. /* Etc.. */

If any one could help me out it would be fantastic, i'm sure it's pretty simple for javascript ppl..
Dec 14 '09 #1
5 1917
RamananKalirajan
608 512MB
Hi,
can you please explain what do you mean by "tag" here. Are you using any div? Instead of using javascript, writing classes in css for those div's are good practice.

Thanks and Regards
Ramanan Kalirajan
Dec 15 '09 #2
Dormilich
8,658 Expert Mod 8TB
Do I guess right, that you want to switch class names?
Dec 15 '09 #3
Yes, I want to switch class names when a tag is applied to a page.
Dec 15 '09 #4
The tags will be coming from php and i guess will look something like this.

Expand|Select|Wrap|Line Numbers
  1. <div class="<?php if ($tag): print $tag; endif; ?>"></div>
Dec 15 '09 #5
Dormilich
8,658 Expert Mod 8TB
well, er, that should do the job?
Dec 16 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Nathan Given | last post by:
Hello All, I am trying to randomly change the background image of my home page but I can't seem to figure it out. Here is a snippet of my css .... BODY {background:transparent...
5
by: AFN | last post by:
I'm trying to set a submit button to change text and color when clicked. Like saying "please wait" instead of "submit" and then changing the background color and text color. All works, except for...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
2
by: Sean | last post by:
Hi all, I have a treeview and because I subclass the treeview and allow multiple selection to be done on the treeview, I have a problem changing the background color of the treeview. The...
2
by: chris_culley | last post by:
Hi there, I've got a gif with (highly) irregular shapes (lots of jigsaw pieces) that I want to map so that each piece is a link... The pieces are currently just a frame drawing, but as they...
4
by: martin1 | last post by:
Hi, want to loop DataSet to change row background color based on data retrieved from sql db, the color can be blue, yellow, red or purple. Therefore, Is there any way (vb.net) to change dataset...
2
by: Mark | last post by:
IE creates an object of every ID'd HTML tag (so it appears), and each object sets a property for any parameter I set in the tag. For example, my HTML might be: <td id='cell1'...
1
by: rockdale | last post by:
Hi, all I am change my webpage to using div and css for my layout, it was using table before and I want to get rid of it. Basically it draws a box around my content using background pictures,...
5
by: moondaddy | last post by:
I have a custom control where users can set the backcolor of one of it's UI elements via a DP I created. One of the colors they can pick is a brush called CustomGradient where I would set the DP...
4
by: html | last post by:
Hello all, I need to change the colour of my text. For the paragraph I do document.fgColor ="blue" ; but how do I do this for the select tags? ....and I prefer it to apply to all select tags...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.