Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> <style> .order[data-order-state="new"] { color: red; } .order[data-order-state="pending"] { color: green; } .order[data-order-state="canceled"] { color: blue; } </style> </head> <body> <div id="order" class="order" data-order-state="new"> New order. </div> <script> // read (order.dataset.orderState); // new // modify order.dataset.orderState = "pending"; // (*) </script> </body> </html>