tags:

views:

19

answers:

2

Hi, 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"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <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

+1  A: 

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
    }
}
BurninLeo
A: 

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

Just put an if statement in your click function.

Gutzofter