简体   繁体   中英

How to click a hyperlink(<a> tag) automatically by clicking only a submit button in html?

<input type='submit' name='btnAdd'  onclick="{{ route('eventCal_index', $_SESSION['title']) }}" value='Add event' >

Submit button should be both work for submission and navigate to that route

That means without clicking the hyperlink, by clicking the submit button I want to click another link automatically. Simply, Is there a way to click a hyperlink( <a> tag) automatically

In the route function at the end of it add

$("#linkid").trigger('click');

Please see this page for more details:- http://www.w3schools.com/JQuery/event_trigger.asp

Try this //on submission of form ,you can trigger click event.

$('form').on('submit',function()      
{
    $('a').trigger('click');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM