Thanks webdev1958 but I would rather use jQuery as I am using it for over things on the site and to be honest I wouldn't know where to start with plain js.
I have been trying and failing again today. Nothing I do seems to have any effect on my links whatsoever - to the extent that I was concerned that jQuery or jQuery colour were not linked properly - but they are.
In case it was not clear from my previous post, the relevant code I have been trying is included on the linked pages, but my server is currently down so I will repeat a simplified version of it here (probably good to do that anyway) in the hope I can get some help figuring out what I am doing wrong.
Here's one version of the query I am trying...
Code:
<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="js/jquery.color.js"></script>
<script type="text/javascript">
var originalBG = $("#projectContent .listings li a").css("background-color");
var fadeColor = "#008BFD";
$("#projectContent .listings li a").hover( function () {
$(this).animate( { backgroundColor:fadeColor}, 450 )
},
function () {
$(this).animate( {backgroundColor: originalBG}, 950 )
}
);
</script>
Here's my css
Code:
#projectContent .listings{display:block; width:780px; border-top:1px solid #008BFD; margin:0; padding:0; float:left}
#projectContent .listings li{list-style:none; padding:0; line-height:1.6em}
#projectContent .listings li a{display:block; width:780px; color:#969991; text-decoration:none; border-bottom:1px solid #666; float:left; padding:0 0 1px 0;background-color:#F5F5F5; }
#projectContent .listings a:hover{background-color:#008BFD; color:#fff;}
</style>
and here's my HTML
Code:
<div id="projectContent">
<ul class="listings">
<li><a href="*">Another Project</a></li>
<li><a href="*">Year</a></li>
<li><a href="*">Location</a></li>
<li><a href="*">Country</a></li>
<li><a href="*">Area</a></li>
</ul>
</div>
Ideally I would like the fade colour to be specified by the a:hover css rather than the js so could I use something like this instead of the above when setting up the variables?
Code:
<script type="text/javascript">
var originalBG = $("#projectContent .listings li a").css("background-color");
var fadeColor = $("#projectContent .listings li a:hover").css("background-color");
$("#projectContent .listings li a").hover( function () {
$(this).animate( { backgroundColor:fadeColor}, 450 )
},
function () {
$(this).animate( {backgroundColor: originalBG}, 950 )
}
);
</script>
I have also tried this
Code:
<script type="text/javascript">
$('.listings li a').hover(function(){
$(this).stop().animate({backgroundColor: '#f5f5f5'});
}, function() {
$(this).stop().animate({backgroundColor: '#008BFD'});
});
</script>
but no luck with that either...
Can some please help me out here and tell me what I am doing wrong - thanks
Bookmarks