How to include javascript in call to linkTo function in volt file


I would like to include the below javascript in my linkTo function call in a volt file. It would help submit the current form when the menu item is clicked. Can this be done or should I use plain php. This jQuery code has been suggested in How to submit a form with JavaScript by clicking a link?


Below is the volt file code where I would like to include it.

<li><?php echo $this->tag->linkto('save', '<span class="glyphicon glyphicon-save"></span> ' . __('Save')); ?></li>


You shouldn't use onclick. There is addEventListener or just $(element).on in jquery