开发者

Stop the onclick if MouseUp

is it possible to deaktivate the onclick Function?

    <!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>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>
        <style type="text/css">
            <!--
            body,td,th {
            font-size: 12px;
            }
开发者_如何学运维            div {
            border:1px solid #444444;
            background-color:#AAAAAA;
            padding:10px;
            margin:10px;
            }
            -->
        </style>
        <script id="ubo_js" language="JavaScript" type="text/javascript">
            $(document).ready(function art()
            {    


            /* IF STATUS == 0 .. abbort the onclick function by mouseup */

            });
        </script>

    </head>

    <body>

        <input id="status" type="text" value="1">
        <br /><br />

        <a href="#" onclick="$('#status').val('0');">switch to 0</a>
        | <a href="#" onclick="$('#status').val('1');">switch to 1</a>

        <br /><br />

        <div class="drot" onclick="alert('hello');">click here</div>



    </body>
</html>

-> working example http://www.jsfiddle.net/V9Euk/43/

kind regards peter


You may give the HTML element an ID,

<a href="#" onclick="$('#status').val('0');" id="element1">

and then just address it and remove the onclick function

var e1 = document.getElementById("element");
e1.onclick = function() {
    alert("leave me alone!");
}

If the method is directly called by the click event, you will need no ID at all, but then you may even use this:

function val() {
    // Do the other stuff on click
    this.onclick = function() {
       // I will do nothing at all
    }
}


Yes it is possible ;). Tongue-in-cheek aside, Are you saying that you want:

Just put an if statement in your click function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜