title: Tidying up javascript with ternary operator
body: <p>I know this code is messy:</p>
  
  <pre><code>$("#tog-desc").click(function(e) {
      $(this).toggleClass("open");
      $(".description").slideToggle();
  
      if( $(this).hasClass("open") ) {
          $(this).html("Hide Description").css("background-position", "85px 3px");
      }
      else {
          $(this).html("Show Description").css("background-position", "88px -10px");
      }
  
      e.preventDefault();
  });
  </code></pre>
  
  <p>But I'm not sure how this could be tidied up with the ternary operator to make it neat and concise. I always seem to end up writing overly long if/else statements with Javascript and I'd like to understand how not to have to do so!</p>
  
  <p>Edit: by default #tog-desc shows "Show Description" and .description is hidden, in case this wasn't obvious</p>
  
  <p>Thanks.</p>