•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,140 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,698 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2428 | Replies: 7
![]() |
this is the input...
<input blah blah blah class='someclasss' onclick='changeSrc(this)'>
.someclass
{
background-image:url(someimage.someformat);
}
function changeSrc(clicked)
{
clicked.style.backgroundImage = 'someotherimage.someformat' //this won't work in IE7!
}
Manipulate the code freely. thanks
<input blah blah blah class='someclasss' onclick='changeSrc(this)'>
.someclass
{
background-image:url(someimage.someformat);
}
function changeSrc(clicked)
{
clicked.style.backgroundImage = 'someotherimage.someformat' //this won't work in IE7!
}
Manipulate the code freely. thanks
You need an id on the same object with someclass. That id becomes the target of the assignment statement:
Put both the class and the id in the object with the background
function changeSrc(clicked)
{
changeme.backgroundImage = 'someotherimage.someformat')
}Put both the class and the id in the object with the background
<body class="someclass" id="changeme">
Daylight-saving time uses more gasoline
•
•
•
•
function changeSrc(clicked)
{
clicked.style.backgroundImage = 'someotherimage.someformat' //this won't work in IE7!
}
javascript Syntax (Toggle Plain Text)
function changeSrc(clicked) { clicked.style.backgroundImage = "url(imageName)"; //the above stmt assumes that the image is present //in the same path as that of the html file }
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- change image one by one (ASP)
- I Need Help Making A Rollover Image! (Geeks' Lounge)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Help needed working with prototype.js and php
- Next Thread: javascript issue



Linear Mode