<form id="detailsForm" method="post" class="ui form" enctype="application/x-www-form-
urlencoded" action="someUrl">
<button class="submitableElement" id="prodDelButton" >
delete
</button>
<input type="text" id="pickupSearchCriteria.pageNumber"name="pickupSearchCriteria.pageNumber" value="1" />
<a class="item paginationAnchor submitableElement" id="1" shape="rect">page1</a>
<a class="item paginationAnchor submitableElement" id="2" shape="rect">page2</a>
</form>
js:
$('.submitableElement').click(function(event){
const id = event.target.id;
doSomeThingWithId(id)//You can use the item id to know what was clicked.
$('#detailsForm').submit()
})
function doSomeThingWithId(id){
alert(`Element with id ${id} was used to submit the form...`);
//Do something here with the data...
}
我认为这或多或少是你需要的,但我建议你重新考虑一下你在那里做的事情是否真的需要。
我的小提琴:
https://jsfiddle.net/ku4rgqne/