title: Do something on :target with javascript
body: <p>I'm using the CSS3 <code>:target</code> pseudo selector to create in-page navigation without reloading the page. This works really well!</p>
  
  <p>But I have a problem, I need to reset the forms in a page when the page targetted, how can I know if an element is targetted with javascript? Like <code>element.ontarget = function();</code></p>
  
  <p>Or maybe something like <code>element.ondisplaychange</code> -> <code>element.oncsschange</code>?</p>
  
  <p><strong>BETTER UPDATE:</strong></p>
  
  <pre><code>var hashcache = document.location.hash;
  window.onhashchange = function() {
      if(hashcache != document.location.hash) {
          $(hashcache + ' form input').each(function() {
              $(this).val('');
          });
          hashcache = document.location.hash;
      }
  }
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code>$('a[href^="#"]').each(function() {
      this.onclick = function() {
          href = $(this).attr('href');
          if(href != document.location.hash) {
              $(href + ' form input').each(function() {
                  $(this).val('');
              });
          }
      }
  });</code></pre>