日期:2014-05-18  浏览次数:20424 次

100 分求一段 js事件代码
<p> <a   href= " "   id= "tbhref "   ondblclick= "execute_a() "> 测试 </a>
        <script   language= "javascript ">
function   execute_a()
{
}
function   execute_b()
{
}

function   selectsubmit(selectname)
{
        if(selectname== "a ")
{
        //这里将id   为 "tbhref "   的单击事件改为     execute_a()  
                          //需求代码
}
else
{
        //这里将id   为 "tbhref "   的单击事件改为     execute_b()
                          //需求代码
}
]
    </script>
   
<input   type= "button "   name= "Submit "   value= "执行a "   onClick= "selectsubmit(a) ">
<input   type= "button "   name= "Submit "   value= "执行b "   onClick= "selectsubmit(b) ">


求以上   "//需求代码 "   注释部分的js程序


谢谢

------解决方案--------------------
function selectsubmit(selectname)
{
var tbhref = document.getElementById( "tbhref ");
if(selectname== "a ")
{
//这里将id 为 "tbhref " 的单击事件改为 execute_a()
tbhref.ondblclick = "execute_a() ";
//需求代码
}
else
{
//这里将id 为 "tbhref " 的单击事件改为 execute_b()
tbhref.ondblclick = "execute_b() ";
//需求代码
}
]
------解决方案--------------------
<p> <a href= " " id= "tbhref " ondblclick= "execute_a(); "> 测试 </a>
<script language= "javascript ">
function execute_a()
{
alert( "a ")

}
function execute_b()
{
alert( "b ")

}

function selectsubmit(selectname)
{
if(selectname== "a ")
{
document.getElementById( "tbhref ").ondblclick = execute_a
}
else
{document.getElementById( "tbhref ").ondblclick = execute_b
}
}
</script>

<input type= "button " name= "Submit " value= "执行a " onClick= "selectsubmit( 'a ') ">
<input type= "button " name= "Submit " value= "执行b " onClick= "selectsubmit( 'b ') ">