I am trying to modify a jQuery that fires an event when either: a) the search text input field is clicked, or b) the search button is clicked
How do I change the code below to instead fire an event when a normal button class is clicked?
$( 'form[role=search] input, form[role=search] button' ).on( 'focus, click', function( event ) {
My button class is ".search-toggle", and I've tried replacing the above code with: $(".search-toggle").click(function( event ) {
but that didn't work.
Here is a rough snippet of the kind of button I'm trying to target.
.search-toggle {
background-color: #028A0F;
color: white;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<ul>
<li style="float:right">
<button type="button" class="search-toggle">Search</button>
</li>
</ul>
</body>
</html>