当前位置: 首页 > 工具软件 > portal-stack > 使用案例 >

html button onclick 列表,javascript - HTML button onclick event - Stack Overflow

双俊人
2023-12-01

You should all know this is inline scripting and is not a good practice at all...with that said you should definitively use javascript or jQuery for this type of thing:

HTML

Online Student Portal

JQuery

var button_my_button = "#myButton";

$(button_my_button).click(function(){

window.location.href='Students.html';

});

Javascript

//get a reference to the element

var myBtn = document.getElementById('myButton');

//add event listener

myBtn.addEventListener('click', function(event) {

window.location.href='Students.html';

});

 类似资料: