javascript - change background color of div using css -


is possible change background color of div using css?

code far:

css

.div{ background-color: #000; }  .live .div:not{ background-color: #ddd; } 

javascript

function change(){ $("body").addclass("live"); } 

html

<div onclick="change()">change</div> <div>...</div> 

everyone seems confused you're trying accomplish. @fedxc has right solution. if you're trying change color of div clicked, it:

html:

<body>     <div>         change div!     </div> </body> 

css:

div{     background-color: #000;     color: white; }  div.live{     background-color: #ccc; } 

javascript:

$("div").click(function(){     $(this).addclass('live'); }); 

live example here: http://jsfiddle.net/7rbdg/1/


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -