When I click the button I want to grab the li from the list and then trigger an event as if I had clicked on the li itself. In other words, I'm trying fire a click event on the menu from the button.
The code I have below returns the document object and not the parent LI.
pen here : https://codepen.io/GerdSuhr/pen/WKZLYQ?editors=1011
$('#switch button').on('click', function(){
var text = $(this).text();
var myLI = $('dl-menu li a span:contains(text)').parent().parent();
console.log(myLI);
//$(myLI).trigger('click.dl-menu');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<ul class="dl-menu">
<li><a href=""><span>aero</span></a></li>
<li><a href=""><span>bio</span></a></li>
<li><a href=""><span>lab</span></a></li>
</ul>
<br>
<br>
<br>
<div id="switch">
<button>bio</button>
</div>