现在的位置: 首页 > 综合 > 正文

js中动态更改事件(如onFocus后改为onclick)

2012年09月17日 ⁄ 综合 ⁄ 共 770字 ⁄ 字号 评论关闭

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script language=javascript>
function _001(obj,xx1,xx2,xx3)
{
        alert("focusValue="+obj.id+"|"+xx1+"|"+xx2+"|"+xx3)
        obj.onfocus=null
        obj.onclick=function()
        {
                _002(obj,xx1,xx2,xx3)
        }
}
function _002(obj,yy1,yy2,yy3)
{
        alert("clickValue="+obj.id+"|"+yy1+"|"+yy2+"|"+yy3)
}
</script>


</head>
<body>
    <form id="form1" runat="server">
    <div>
   <input id="txt" type="text" name="t_xt" onfocus="_001(this,1,2,3);">
    </div>
    </form>
</body>
</html>

抱歉!评论已关闭.