title: button OnClick event not firing
body: <p>There is a page and I am trying to attach an onclick event to the button ("SEARCH CRUISES") on the page but the onclick event is not firing correctly. Here is my code:</p>
  
  <pre><code>&lt;script&gt;
  debugger;
  var x = document.getElementsByClassName("cdc-filters-search-cta")
  
  for (i=0; i&lt; x.length; i++){
      if(x[i].text.trim().indexOf("SEARCH") &gt;= 0 &amp;&amp;  x[i].text.trim().indexOf("CRUISES") &gt;= 0){
          x[i].onclick = function(){
              console.log("Search button clicked");           
          };
          break;
      }   
  }   
  </code></pre>
  
  <p></p>
  
  <p>Here is the complete html: <a href="https://jsfiddle.net/g0tkqrx6/" rel="nofollow noreferrer">https://jsfiddle.net/g0tkqrx6/</a></p>
  
  <p>I have tried attaching the onclick event to the object in many different ways but I am not able to get the click event to fire. I would appreciate if anybody can provide some insight as to what I could be doing wrong here.</p>
  
  <p>Thanks in advance</p>