Hacker News new | ask | show | jobs
by pgcj_poster 1798 days ago
There's already a :checked selector, so you don't really need JavaScript at all in this example.

  <input type="checkbox" id="discount">
  <label for="discount"></label>
  <style>
    #discount + label:before {
      content: "Click me to apply fake discount!";
    }
    #discount:checked + label:before {
      content: "Click on me to remove fake discount";
    }
    #discount + label:after {
      content: "You have not availed discount";
      display: block;
    }
    #discount:checked + label:after {
      content: "Discount Availed!";
    }
  </style>
1 comments

Even better!