Reputation:
I am using the following HTML:
<form action="/User/Account/LogOff" id="logoutForm" method="post">
<button class="float-left submit-button" title="Logoff">Logoff</button>
</form>
I would like to replace this with:
<form action="/User/Account/LogOff" id="logoutForm" method="post">
<div class="button" id="logout" title="Logout">
<span>Logout</span>
</div>
</form>
Is there a way that I can catch a click on the div#logout and use this as a submit for the form? I saw this for a link:
<a href="javascript:document.getElementById('logoutForm').submit()">Logout</a>
But how could I do it for a DIV like mine?
Upvotes: 0
Views: 6657
Reputation: 2742
Add this into your DIV:
<div class="button" id="logout" onclick="javascript:document.getElementById('logoutForm').submit();" title="Logout">
EDIT 1: Thanks for pointing out.
<div class="button" id="logout" onclick="submitForm()" title="Logout">
Javascript:
function submitForm()
{
document.getElementById('logoutForm').submit();
}
Upvotes: 2