想设计3个按钮,点击某个按钮后该按钮变色,其它两个按钮恢复默认色。
With wb.AddButtonGroup("form1", "btn", False)
.Add("btn", "111", "submit").Value = "btn1"
.Add("btn3", "222", "submit").FormAction = "accept.htm"
.Add("btn4", "333", "submit").FormAction = "accept.htm?type=1&model=ha"
End With
wb.AppendHTML("<link rel='stylesheet' href='./lib/anniu.css'/>", True) '引入样式文件
wb.AppendHTML("<script src='./lib/anniu.js'></script>") '引入脚本文件
那就不能使用submit,改为使用button,然后按钮绑定onclick事件,事件里调用函数,在函数里处理按钮的样式
With wb.AddButtonGroup("form1", "btn", False)
With .Add("btn1", "自定义", "button") '自定义按钮
.Attribute = "on click=""click()"""
End With
End With
click函数:
function click(){
var button = document.getElementById("btn1");
button.style.backgroundColor = "blue";
button.style.color = "white";
button.style.border = "1px solid red";
}
我这样写没成功,哪里不对?
[此贴子已经被作者于2024/7/8 15:52:18编辑过]