0

Below is my code, i just want to alert the "hi" and "hello" so that i can put my actual codes there.

<html>
<head>
<script type="text/javascript"  src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
    document.write(unescape("%3Cscript src='jquery-1.11.1.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>

  <script src="jquery-ui.js"></script>
        <link rel="stylesheet" href="jquery-ui.css">
</head>

<script>

$(document).ready(function(){
    alert("hi");
    $('form[name="lgform"]').submit(function(evnt){
        evnt.preventDefault();
    });

    $("#btn_login").click(function(){       
        alert("hello");
    });

});
</script>

<body>
<form name="lgform">
<div>

<table id="table"  >
    <tr>

        <td width="35px"><input id="mob"  type="text" name="mob_nu"></td>

        <td width="35px"><input id="pswd"  type="password" name="pswd_vl"></td>

        <td width="100px"><input type="button" name="login_btn" id="btn_login" value="Login"></td>          
    </tr>

</table>
</div>
</form>

</body>
</html>

button click event is not working, i am using the same jquery library in some other places which is working fine. I have to call ajax in this page i need to call the button click without submitting the page, as i have few more buttons to add. Any piece of code is appreciated and thanks in advance.

6
  • Did you debug this in the firebug may be some of your jquery libraries are loading properly Commented Jul 23, 2015 at 17:18
  • works fine for me. check this jsfiddle.net/n8roc39p. as @MuhammadHisham suggested, are you missing any libraries? can you check your console for errors? Commented Jul 23, 2015 at 17:33
  • Code works fine for me too as per your requirement...I think you/moderator should close or delete this question. Commented Jul 23, 2015 at 17:37
  • @muhammed Hisham i am using eclipse Commented Jul 23, 2015 at 17:38
  • @Sushil no errors in console. but not working for me Commented Jul 23, 2015 at 17:39

1 Answer 1

1

when i tried your code i got this error

Ignored call to 'alert()'. The document is sandboxed, and the 'allow-modals' keyword is not set

and when i tried after replacing alert's with console.log then it is working fine.

Your code is working fine, replace alert's with console.log()

Sign up to request clarification or add additional context in comments.

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.