首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

一个调用function的有关问题

2012-03-11 
一个调用function的问题?scriptfunctiontest1(){alert(1)}functiontest2(){alert(2)}/scriptinputt

一个调用function的问题?
<script>
function   test1()
{
alert(1);
}

function   test2()
{
alert(2);
}
</script>
<input   type= "button "   onclick= "test1(); "   id= "test ">

在不能修改test1()和input的代码和不能对input进行操作,如document.getElementById( "test ").attachEvent( "onclick ", "test2 ")等的情况下
按下button执行test1()后,再执行test2()

[解决办法]
<script>
function test1()
{
alert(1);
}

function test1()
{
alert(1);
alert(2);
}
</script>
<input type= "button " onclick= "test1(); " id= "test ">
[解决办法]
<script>
function test1()
{
alert(1);
}

function test2()
{
alert(2);
}

document.onclick=function(){
if(event.srcElement.id== "test " && event.type== "click ") test2();
}
</script>

<input type= "button " onclick= "test1(); " id= "test ">
[解决办法]
hb的算不算修改test1呢? :)
[解决办法]
<script>
function test1()
{
alert(1);
}

function test2()
{
alert(2);
}
var t = test1;
test1 = function(){ t(); test2();}
</script>
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
[解决办法]
<script>
function test1()
{
alert(1);
}

function test2()
{
alert(2);
}

</script>
<div onclick= "if((event.srcElement||event.target).type== 'button ') test2(); ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">


</div>

热点排行
Bad Request.