title: Get Ancestor by class name
body: <p>I have a component which have buttons and list both of which perform events on click. I need a common way to get the ancestor element for these elements. The structure looks like</p>
  
  <pre><code>&lt;div class='a'&gt;
     &lt;button class ='b' data-name="hello"&gt;
        &lt;span class ='c'&gt;clickMe
           &lt;span&gt;somehting&lt;/span&gt;
        &lt;/span&gt;
     &lt;button&gt;
     &lt;ul class ='d'&gt;
        &lt;li data-name="about"&gt;
            &lt;span class ='e'&gt;something here
               &lt;span&gt;somehting&lt;/span&gt;
            &lt;/span&gt;
        &lt;/li&gt;
        &lt;li data-name="home"&gt;
            &lt;span class ='e'&gt;something elser here
                &lt;span&gt;somehting&lt;/span&gt;
            &lt;/span&gt;
        &lt;/li&gt;
     &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I try to get the element button and li because I need to get data-name information. 
  e.target is the element that was clicked</p>
  
  <pre><code>var targetel = goog.dom.getAncestorByClass(e.target,null,class??);
  </code></pre>
  
  <p>Not sure how to get the correct element irrespective if its a button or li. Do i need to add a unique class to all the elements ?</p>