那就看你怎么写两个的click事件了。
写在两个函数中, 第一个用
obj.style.display = (obj.style.display=="none")?"":"none";
第二个就看你的了。
写在两个函数中, 第一个用
obj.style.display = (obj.style.display=="none")?"":"none";
第二个就看你的了。
解决方案 »
- $("div").load('demo_ajax_load.txt');会影响seo吗?
- JS获取IE表单自动完成值,如何做到
- 为什么加了空格显示方式就完全不同呢
- 〖求一段 Javascript 代码〗: 打开一个页面, 查找某个链接的地址, 再打开其指向的内容.
- 怎么点击一个链接文字(add)后.链接文字变为(ok).然后(OK是普通文本.不是链接文本)
- 统计可多行输入的文本框输入的字符数问题~!
- 判断输入框为空或者是全部为空格的问题!
- 如何关掉javascript打开的页面, 谢谢
- 最基本的问题
- 复选框问题...谢谢 !
- 如何让IE弹出窗口最上面的标题栏隐藏?
- 一个window.showModalDialog的问题!!!!!!!!1
你说的是显示和隐藏,而没有区分是button1还是button2的动作
<input type="button" name="button1" onclick="showAndHide()"/>
<input type="button" name="button1" onclick="modifyContent()"/>showAndHide负责显示和隐藏
modifyContent负责修改内容,不冲突吧
<head></head>
<body>
<form name="form1" method="post" action="">
<input type="submit" name="Submit" value="提交" onClick="javascript:alert(this.name);">
</form>
</body></html>
参考:
<script>
var flag_1=true;
var object_1;
function alertTest(obj)
{
if (object_1==null){
object_1=obj;
}
if (obj==object_1){
flag_1= !flag_1;
if (flag_1)
document.all.divTest.style.visibility="visible";
else
document.all.divTest.style.visibility="hidden";
}object_1=obj;
}</script>
<input type="button" name="Submit4" value="按钮1" onClick="alertTest(this)">
<input type="button" name="Submit5" value="按钮2" onClick="alertTest(this)">
<div id="divTest" style="position:absolute;top:20;left:100; width:200px; height:115px; z-index:1; visibility: visible; background-color: #558ABF; layer-background-color: #558ABF; border: 1px none #000000;"></div>
input{t:expression(this.onclick=function(){check(this)})};
</style>
<script>
function check(obj)
{
if(obj.name=='button1')
{
//button1处理事件
}
if(obj.name=='button2')
{
//button2处理事件
}
}
</script>
<body>
<input type='button' value='按钮' name='button1'>
<input type='button' value='按钮' name='button2'>
</body>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
function cc()
{
var c = event.srcElement;
var a = document.getElementById("aa"); switch(c.value)
{
case "button1":
if(a.style.display=="")
{
a.style.display = "none";
}
else
{
a.style.display="";
}
break;
case "button2":
a.innerText = "2343";
break;
}}
//-->
</SCRIPT>
</HEAD><BODY>
<div id=aa style="width:100px;height:100px;border:1px solid red;">sdf</div>
<input type=button value=button1 onclick="cc()">
<input type=button value=button2 onclick="cc()">
</BODY>
</HTML>
alert("这是Button1的动作");
else if(event.srcElement.name=="Button2")
alert("这是Button2的动作");