1

I am wondering why javascript alerts doesn't popup:

asp.asp file:

<html>
<head>
<meta charset="utf-8">
<title>AAA</title>

   <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

  <script class="code" language="javascript" type="text/javascript">
    $(document).ready(function(){
            $( "#btn-statistika" ).click({
                alert('ok');
            });
            $( "#btn-lokality" ).click({
                alert('ok');
            });
    });
  </script>
</head>
<body>

<button class='ui-state-default' id='btn-statistika' style='' >Statistika</button>
<button class='ui-state-default' id='btn-lokality' style='' >Lokality</button>

</body>
</html>

Another asp files are working, I don't know why this cannot work...

2 Answers 2

4

You need to pass a function as param to click() call

$(document).ready(function () {
    $("#btn-statistika").click(function () {
        alert('ok');
    });
    $("#btn-lokality").click(function () {
        alert('ok');
    });
});
Sign up to request clarification or add additional context in comments.

Comments

0

Here is the updated code

<html>
<head>
<meta charset="utf-8">
<title>AAA</title>

   <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

  <script class="code" language="javascript" type="text/javascript">
    $(document).ready(function(){
            $( "#btn-statistika" ).click(function(){
                alert('ok');
            });
            $( "#btn-lokality" ).click(function(){
                alert('ok');
            });
    });
  </script>
</head>
<body>

<button class='ui-state-default' id='btn-statistika' style='' >Statistika</button>
<button class='ui-state-default' id='btn-lokality' style='' >Lokality</button>

</body>
</html>

Note: You need to pass a function() in click({}); event.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.