本文摘自PHP中文网,作者藏色散人,侵删。
html提交按钮改字的方法:1、直接修改value属性,代码如“onclick="getPasswd()" value="显示"...”;2、修改button的innerHTML,代码如“type="button" onclick...”。

本文操作环境:windows7系统、HTML5版、Dell G3电脑。
修改html中button显示的文字
1. <input type="button"> 实现密码输入框的可见和隐藏
直接修改value属性即可
1 2 3 4 5 6 7 8 9 10 11 12 13 | <script type= "text/javascript" >
function getPasswd(){
var passwd = document.getElementById( "pwdID" );
var pwdBtn = document.getElementById( "pwdBtnID" );
if (passwd.type== "password" ) {
passwd.type= "text" ;
pwdBtn.value= "隐藏" ;
} else {
passwd.type= "password" ;
pwdBtn.value= "显示" ;
}
}</script>
密码:<input id= "pwdID" type= "password" ><input id= "pwdBtnID" type= "button" onclick= "getPasswd()" value= "显示" >
|
2. <button> 实现视频的播放和暂停
修改button的innerHTML
1 2 3 4 5 6 7 8 | <script type= "text/javascript" > function playVideo(){ var videop = document.getElementById( "videoId" ); var videoBtn = document.getElementById( "videoBtn" ); if (videop.paused){
videop.play();
videoBtn.innerHTML = "暂停" ;
} else {
videop.pause();
videoBtn.innerHTML= "播放" ;
}
}</script><button id= "videoBtn" type= "button" onclick= "playVideo()" >播放</button>
|
3. innerHTML、innerText、outerHTML、outerText
innerHTML是符合W3C标准的属性,其它属性不推荐使用
下面是id=innerId的p几个值的对应结果

【推荐教程:《html视频教程》】【推荐教程:CSS视频教程 】
以上就是html提交按钮怎么改字的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
form标签的action属性怎么用?form标签action属性的用法介绍(附实例)
Html中的空链接有什么用
Html怎么设置文字大小
Html元素语法介绍
Html 导出到 excel
Html怎么和js连接
Html表格合并单元格的方法
Html中新建表格怎么加背景
Html如何让字体自动变色
Html如何实现鼠标悬停提示a标签内容
更多相关阅读请进入《Html》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » html提交按钮怎么改字