作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有这个按钮,只要你点击另一个按钮就会加载(所以它不会在启动时加载而我没有做任何事情)
<button type='button' id='testbtn'
onclick='testfunction()' onload='testload()'
class='testbtnclass'>btn</button>
这是我的功能:
function testload() {
alert("onload worked");
/*what i want to archieve within this function later is to change the
css of the button but for now i just want to call this function onload of
the button, which it doesnt/*
}
我现在的问题是,我应该怎么做才能在加载此按钮时运行此功能?
最佳答案
onload
不受 button
标签支持,因此您需要像其他答案一样或使用
document.onload =function(){
//change the css of that button or call function you want
}
关于javascript - 如何将样式添加到单击另一个按钮时创建的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29962851/
我是一名优秀的程序员,十分优秀!