Changing Background Image/colour?
Jun 14, 2010
I'm having a problem with changing the background image on an element when I use the .hover() and .toggleClass() methods. Here's some code:
First the CSS:
Code:
.down-arrow {
cursor: pointer;
background: #efefef url(images/arrow-down.png) no-repeat 13px 13px;
[Code]....
It seems to work ok(ish) if I use the .css() method and change it directly in the code, but I want to try and keep my styling only in my CSS file and use classes to make the change.
View 2 Replies
ADVERTISEMENT
Jul 23, 2005
I spotted some nice code to change the background colour of a web page to
one of four different colours at random but I can't find it now!
The method was to select a number at random from 1 to 4 by using the rnd()
function and then dividing by modulus 4. The result was then used to select
a cell in a 4 cell array which was holding a different colour in each cell
of the array. I would like to have this code but lack the knowledge to
re-create it.
View 4 Replies
View Related
Sep 22, 2009
I am using javascript code to change the background colour and font colour of some elements called 'filled') dynamically. For example:
if(timeInputValue >= startcode && timeInputValue < endcode && stateInput.value == "playing") {
filled.style.backgroundColor = '#ffffff';
filled.style.color = '#000000';
}
I also want to put a border around these 'filled' elements too - how can I do this is javascript? I can't find an equivelent to style.border = "1px"
View 1 Replies
View Related
Jun 10, 2009
EDIT: for some reason it is working now, but i have a new question: how do i change the background to no background?
View 5 Replies
View Related
Sep 29, 2011
i want to set dynamically a div's background image when the page loads, so I have my code like so:
javascript code:
window.onload = init;
function init(){
$(document).ready(function(){
$('#button1').css('background', 'url(../imagenes/buttonNormal.jpg)');
$('#pg1').css('color', 'black');
[Code]...
View 2 Replies
View Related
Sep 26, 2009
I've been trying to figure out how to change the background image with javascript, and I've tryed a whole bunch of code this being one of them
var imageURL = "/images/content/rotator/IMG_2019.jpg";
document.body.style.backgroundImage = "url(" + imageURL + ")";
or
document.body.style.backgroundImage = "/images/content/rotator/IMG_2019.jpg";
or
document.body.background = "/images/content/rotator/IMG_2019.jpg";
With using the last one I get 'document.body' is null or not an object, but I do have a <body> tag in my page.And if I do
if (document.body){
alert("hello");
}
I dont get anything.How can I get this code to work?
View 4 Replies
View Related
Apr 23, 2009
I am using PHP and Javascript to create a user generated page editor. I have everything working except one thing. The user can select the background color of the page using preselected colors. They can also enter in a hexadecimal code to change the color of the background if the color they want isn't one of the preselected ones. These two things work good, but when it comes to them entering in a web address to make an image the background instead of a color, I can't get the background image to change. I have tested it out and when I enter in a predetermined url in the javas source code to test if the pic will display it does, but it doesn't go away after being displayed. So my question is using the code below, how can I get the change the background image using an input box and how can I make it go away when a color is selected instead of an image. Explained below:
[Code]...
View 2 Replies
View Related
Apr 26, 2011
After you click on the last button 3 times it should change the background to the zombies image however it isn't working. I haven't found tutorials for doing it exactly as I am attempting it but I don't see why this isn't working.It runs through the code just fine and the button works as intended except for the fact that the background image isn't changing.
<html>
<title>Welcome :D</title>
<head>[code]....
View 11 Replies
View Related
Jun 30, 2011
I want javascript to change the background image on hover.
This is my javascript:
function navOver(obj){
var imgUrl = 'url(images/' + obj.id + '.hover.png) center no-repeat';
obj.style.background='imgUrl';
}
function navOut(obj){
[Code]...
View 5 Replies
View Related
Jul 1, 2010
I have found a method which works in FireFox (2 - 3.6) & Mozilla but obviously it is not generic and IE is proving difficult to provide an attribute I can change. This (in essence) is what I am doing. I do have CSS styles and set the background (fixed, repeated) there in a style called body. The one below is an exapmple - I change the URL of the IFRAME contents several times before dumping the filtered table in the innerHTML. This leaves the background as the last one set.
Code:
body{
background-attachment: fixed;
background-image: url(images/gcount.jpg);
[Code]...
View 1 Replies
View Related
Sep 13, 2010
I am trying to make a button that would change the background image whenever somebody clicks it.
I have tried something along the lines of this:
Quote:
<input type="button"
value="Pattern1"
onClick="background-image: url(background.png);background-repeat: no-repeat;">
[Code]...
View 5 Replies
View Related
Sep 13, 2010
I am trying to make a button that would change the background image whenever somebody clicks it. I have tried something along the lines of this:
<input type="button"
value="Pattern1"
onClick="background-image: url(background.png);background-repeat: no-repeat;">
and,
<input type="button"
value="Pattern2"
onClick="background: url(background.png);background-repeat: no-repeat;">
as you can see, I am a beginner at coding in general. My assumption to why it doesn't work is that I am combining javascript with CSS, but I am most likely wrong.
View 4 Replies
View Related
Mar 18, 2010
I can successfully change the background image using the following:
jQuery(document).ready(function($) {
$("div#largeimage").randombg({
directory: "http://path/to/imgs", //directory to image folder
howmany: 3 //how many images are in this folder
});
});
But, what I want to do is change this ONCE per user session. So instead of change this on every refresh / page load I want to load it once, store that setting in a cookie/session, and not do it again until the next session.
View 1 Replies
View Related
Apr 7, 2010
Here's my code (it is fired, and does find the object, but won't change the background image): But it's not the image that's the problme, because even trying to change the background-color doesn't work either.[code]...
View 3 Replies
View Related
Mar 21, 2011
I want to change the background of my main div depending on the time of day. Right now this code works for two time of day, day and night but it only works on the "body" tag not on a div. How would i modify it to change a div background rather then the "body" background
[Code]...
View 6 Replies
View Related
Feb 25, 2010
I want to let the user change the background image via a select box:
jquery:
$("#selectOverlay").change(function() {
var theOption = $(this).val();
$("header .inner, .overlayBottom").css("background-image", theOption);
[code]....
Only works in FF. Not chrome, opera, or IE.
View 6 Replies
View Related
Sep 10, 2009
I'm just trying to do something pretty simple which is an alert box which will give me the background color. So simple that it doesn't want to work, that is!
The line the body is onmouseover: <p id="metallic" onMouseOver="switchElementColour('metallic');">metallic c-prints</p>
The function is as follows
function switchElementColour(elementName){
var tryId = document.getElementById(elementName);
var yrf = tryId.style.backgroundColor;
[Code]...
View 4 Replies
View Related
Mar 21, 2009
I wish to change the background colours of two divs, one is blue and the other is gray.i already have the pull down onchange working that changes the fields to active or disabled depending on the selection made and wish to change the background to gray out the div that has disabled fields.how is this done using Javascript
View 1 Replies
View Related
Sep 8, 2011
The button is a blob of colour (.jpg) with text over the top. I want two things to happen: first, when the cursor is rolled over the .jpg and then the text, I want the text to change colour. This works ok. Second, I want to link to industry.php when clicked. This works ok over the .jpg but, obviously, not over the text.
[code = PHP]
echo '<div id="industry_button"><a href="industry.php" onmouseover="Roll_Industry(true)" onmouseout="Roll_Industry(false)">
<img name="Industry" src="graphics/industry_button.jpg" width="133" height="30" /></a>
[Code]....
View 4 Replies
View Related
May 5, 2009
trying to get the javascript function into the divs background colour.The javascript function finds a cookie with a hex code and then the div is ment to add the code as its background colour.
<script type="text/javascript">
function imgcolour() {
color1=getCookie('color1');
[code]...
View 7 Replies
View Related
Jul 30, 2011
I've tried to adapt some pre-existing scripts to do this but not getting anywhereI have five navigation div's.They are:
#navtab1
#navtab2
#navtab3
[code]....
View 3 Replies
View Related
Feb 28, 2011
How would I go about changing the colour of a div, using a list-box, as opposed to buttons? I think I have figured out how to create the list box, but I am stumped as to what to do using Javascript.
Looking on Google, there is no much help on what I am trying to do (e.g. there is only code on changing div colours via an image hover etc).
[Code]...
View 3 Replies
View Related
Oct 3, 2011
How come this isn't working?
document.getElementById('glance').style.display='block'.color='gold';
View 3 Replies
View Related
Feb 10, 2011
I am trying to make a way to toggle the background colour of a page.
I have managed to find this way, but instead of two seperate links I just want to have an icon which when clicked once changes the colour and changes the icon, then clicked again returns to the other colour and replaces the icon.
Here is my code so far:
View 3 Replies
View Related
Dec 22, 2010
I'm trying to use javascript to have my webpage black at night and bright blue (#2A7FFF) in the day time. How would I go about this? ::confused: I have also tried to use javascript to change a picture depending on the time of day, this is what I have used.
IN THE <head>
<script type="text/javascript">
var hourofday = thedate.getUTCHours();
function sun()
[Code]...
View 4 Replies
View Related
Apr 20, 2011
I've been using this bit of code to limit the number of characters in a text field (taken from http://www.shiningstar.net/articles/articles/javascript/dynamictextareacounter.asp:
<SCRIPT LANGUAGE="JavaScript">
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
[code]....
View 2 Replies
View Related