0
我使用下面的HTML:如何點擊DIV使用javascript提交表單?
<form action="/User/Account/LogOff" id="logoutForm" method="post">
<button class="float-left submit-button" title="Logoff">Logoff</button>
</form>
我想,以取代本:
<form action="/User/Account/LogOff" id="logoutForm" method="post">
<div class="button" id="logout" title="Logout">
<span>Logout</span>
</div>
</form>
有沒有一種方式,我可以趕上在div#註銷點擊,並以此作爲提交表單?我看到這個鏈接:
<a href="javascript:document.getElementById('logoutForm').submit()">Logout</a>
但我怎麼能這樣做,像我這樣的DIV?您指出 感謝:
只使用一個提交按鈕,如果你不使用任何客戶端驗證。那的好不要使用不必要的JS,爲您註銷甚至dosent想要的形式。它能成爲一個鏈接 –
你可以試試這個鏈接的解決方案http://stackoverflow.com/questions/6366087/submit-data-on-div-click – Surabhi