Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

JQuery Fade Background Image but not entire div's text

Posted on 2009-05-17
1
2,906 Views
Last Modified: 2012-06-21
I have the following CSS and HTML. I have the main div's background as an image, I want to fade the image bu not the entire div. When I run the following code the fade entire div fades but I just want the background image to fade not the text "test"
////CSS
#pagewidth{ 
background:url(images/bg_normal.jpg) right top no-repeat;
width:1024px;
text-align:left;
margin-left:auto;
margin-right:auto;
} 
 
///HTML
<link rel="stylesheet" href="includes/css/css.css" type="text/css" />
<script type="text/JavaScript" src="includes/jquery.js"></script>
</head>
<script type="text/JavaScript">
jQuery(document).ready(function($) {
		$('#pagewidth').fadeTo("fast", 0.4);
});
</script>	
<body>
	<div id="pagewidth">
			<div id="wrapper" class="clearfix" > 
			<div id="maincol" >test</div>
			</div>
	</div>
</body>
</html>

Open in new window

0
Comment
Question by:phper
1 Comment
 
LVL 12

Accepted Solution

by:
alien109 earned 500 total points
ID: 24406286
You can't fade just the background of a div tag. Fading will affect the entire element, and all child elements.
To achieve the effect you want, you'll need to place a div inside of pagewidth which is a sibling of the div with the test "test" and then fade that.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
document.write() deleting all existing HTML 5 49
Dynamic Dropdowns 15 32
Add or delete table rows 10 53
Is there a way to bind the ID to the text value of the search result? 28 51
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question