RIRedinPA Posted April 12, 2010 Share Posted April 12, 2010 Is there a way with javascript to change a css class? If I have a class #content p.checkbox { padding: 4px 1px 0 0; height: 31px; background-color: #fff; } and want to change the background color to #ff0000 on a mouseover is there javascript to allow that? Quote Link to comment Share on other sites More sharing options...
JustLikeIcarus Posted April 12, 2010 Share Posted April 12, 2010 Here is the jQuery version of that. Just include the jQuery library in the head <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> Then add this. <script type="text/javascript"> $(document).ready(function(){ $('#content p.checkbox').hover(function(){ $(this).css('bacground', '#ff0000'); }, function(){ $(this).css('bacground', '#ffffff'); }); }); </script> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 12, 2010 Share Posted April 12, 2010 A bit extensive to include a library for one functionality. Anyway, not sure if this works: #content p.checkbox:hover { background-color: #ff0000 !important; } I don't even understand the concept of this. You want to change the checkbox background color? Quote Link to comment Share on other sites More sharing options...
JustLikeIcarus Posted April 12, 2010 Share Posted April 12, 2010 A bit extensive to include a library for one functionality. Anyway, not sure if this works: #content p.checkbox:hover { background-color: #ff0000 !important; } I don't even understand the concept of this. You want to change the checkbox background color? That will work but not for IE Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 12, 2010 Share Posted April 12, 2010 That will work but not for IE Nothing ever works in IE. It's such a fail browser. It fails on many performance tests. 1. You misspelled "background". 2. It's "background-color". 3. Does that also overwrite "!important" background colors if there is one? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.