1

I'm trying to make the entire area of each li in a ul click to the <a> inside each li. Wordpress 5.41 (if that makes any difference.)

<ul class="six-corners">
  <li id="button_parents">
     <h3><a href="/parents">Parents</a></h3>
  </li>
  <li id="button_schools">
     <h3><a href="/schools">Schools</a></h3>
 </li>

etc...

And this jQuery:

jQuery(".six-corners li").click(function(event) { 
   if (! jQuery(event.target).is('a')) {
      var a = jQuery(this).find("a");
      a.trigger('click');
    }
});

What happens is that the 'a' appear to be clicked (the link flashes as though clicked), but the page doesn't actually go to the new location.

What am I doing wrong?

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
jchwebdev
  • 5,034
  • 5
  • 21
  • 30
  • It sounds like you prevent default, which is definitely not seemed in your code, but when testing this in a JSFiddle everything worked ok... Does jQuery loads well? Can you share a URL or test environment? – Shalev Levi Jun 13 '20 at 22:00
  • @Shalev Levi: How do I figure out where the preventDefault is coming from? – jchwebdev Jun 13 '20 at 22:03
  • why are you trying those custom code? when you click a, then you can be redirected to other page. I can't understand. please provide more details. – WebDev Jun 13 '20 at 22:03
  • As I said, because the users want to be able to click -anywhere- inside the
  • (each li has a very large image as a background)
  • – jchwebdev Jun 13 '20 at 22:04
  • Why don't you make the `` a block element to fill the whole `
  • ` and let browser do the redirect?
  • – charlietfl Jun 13 '20 at 23:19