{"id":32,"date":"2005-11-06T17:13:50","date_gmt":"2005-11-06T22:13:50","guid":{"rendered":"http:\/\/www.juixe.com\/techknow\/index.php\/2005\/11\/06\/style-and-class\/"},"modified":"2005-11-06T17:13:50","modified_gmt":"2005-11-06T22:13:50","slug":"style-and-class","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2005\/11\/06\/style-and-class\/","title":{"rendered":"Style And Class"},"content":{"rendered":"<p>With JavaScript you can access and update an element\u00c3\u00a2\u00e2\u201a\u00ac\u00e2\u201e\u00a2s style and even its class.  Say that you have two CSS classes:<\/p>\n<pre>\n.warning {color: yellow;}\n.error {color: green;}\n<\/pre>\n<p>You can update or switch an element\u00c3\u00a2\u00e2\u201a\u00ac\u00e2\u201e\u00a2s CSS class with the following JavaScript code:<\/p>\n<pre>\nvar element = document.getElementById('element');\nelement.className = 'warning';\n<\/pre>\n<p>But you can access individual CSS attributes via an element\u00c3\u00a2\u00e2\u201a\u00ac\u00e2\u201e\u00a2s style object, such as<\/p>\n<pre>\nvar element = document.getElementById('element');\nelement.style.color  = 'green';\n<\/pre>\n<p>Of course, you might update an element\u00c3\u00a2\u00e2\u201a\u00ac\u00e2\u201e\u00a2s style based on some event or in conjunction of an Ajax call.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With JavaScript you can access and update an element\u00c3\u00a2\u00e2\u201a\u00ac\u00e2\u201e\u00a2s style and even its class. Say that you have two CSS classes: .warning {color: yellow;} .error {color: green;} You can update or switch an element\u00c3\u00a2\u00e2\u201a\u00ac\u00e2\u201e\u00a2s CSS class with the following JavaScript code: var element = document.getElementById(&#8216;element&#8217;); element.className = &#8216;warning&#8217;; But you can access individual CSS attributes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[9,16,3],"tags":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-w","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/32"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":0,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/32\/revisions"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}