Eddie Shipman
asked on
Toggle only certain anchor
I have this HTML:
<a id="open" class="open" href="#">Log In | Create Account</a>
I have a click event to toggle the wording like this:
<li id="toggle">
<a href="/store/customer/account/logout/">Logout</a>
<a id="close" style="display: none;" class="close" href="#">Close Panel</a>
</li>
Sometimes the first anchor will be like this:<a id="open" class="open" href="#">Log In | Create Account</a>
I have a click event to toggle the wording like this:
// Switch buttons from "Log In | Register" to "Close Panel" on click
$("#toggle a").click(function(event) {
event.preventDefault();
$("#toggle a").toggle();
});
How would I trigger the toggle() only when the first anchor has an id = 'open'?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I understood the requirement was for the toggle function not the click function
ASKER
Actually did it a little different but both answers helped me.