I want to change the css attribute of a div on hover like
$(function(){
$("div#box").hover({
$("div#box").css({z-index:'12'});
});
});
Dreamweaver is giving me a syntax error. Can anyone please tell what is the problem?
Try
$(function(){
$("div#box").hover(function(){
//hover on
$("div#box").css({zIndex:'12'});
},
function(){
//hover off
$("div#box").css({zIndex:''});
});
});
$(, not $.(..hover(function(){ instead of .hover({. As it is, you're creating an object literal, which I don't think is what you want.Try this
$(function(){
$("div#box").hover(function(){
$("div#box").css('z-index', '12');
});
});
css call shouldn't need to be changed -- it can take a map (object literal).{zIndex:12} works though, jsfiddle.net/jvkjF/2)z-index). I only noticed that you had changed it from the map overload to the two-strings overload -- I missed the bit where you had also put quotes around the z-index.Altogether, I have just commented how to use animation and classes.
$(document).ready(function() {
$('div#box').hover(
function(){
$("div#box").css({zIndex:'12'});
//$(this).find('img').animate({opacity: ".6"}, 300);
//$(this).find('.caption').animate({top:"-85px"}, 300);
//$(this).removeClass().addClass("someClassName");
},
function(){
$("div#box").css({zIndex:''});
//$(this).find('img').animate({opacity: "1.0"}, 300);
//$(this).find('.caption').animate({top:"85px"}, 100);
//$(this).removeClass().addClass("someClassName");
}
);
});