Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-03-2012, 03:35 PM   PM User | #1
m2244
Regular Coder

 
Join Date: Jun 2012
Posts: 129
Thanks: 1
Thanked 1 Time in 1 Post
m2244 is an unknown quantity at this point
Can I use jQuery to replace an image

Hello,

As the title says I am trying to replace an image on the page with another image. It appears to be working but I believe that the old image is still there. Is there a better way to do this? Should I remove the old image before I add the new one?

Code:
$(".bannerImage").css('background-image','url("course_assets/banner_grey.png")');
Code:
.bannerImage{
	background:url('../course_assets/banner.png')no-repeat;
	height: 88px;
	width: 100%;
}
m2244 is offline   Reply With Quote
Old 12-03-2012, 06:35 PM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,530
Thanks: 0
Thanked 503 Times in 494 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
If that's the only script on your page then a better way would be to forget about jQuery and use a single JavaScript statement in place of the entire library.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:44 PM.


Advertisement
Log in to turn off these ads.