在别人的网站上看到这样一个小东西。搞了半天。也没搞明白。希望有高手指点一下,实际上是点击文字链接。弹出一个登陆的层。但是他们是直接通过下面这样的方式的<a id="jsOpenLogin" href="login.php" title="登陆">登陆</a>他们这样直接点击。会弹出一个登陆的层而我从头写的时候。怎么也弹不出提示。要怎么写才能不让他直接连接到login.php,而是弹出一个提示?我这样写不行$("#jsOpenLogin").bind("click",function(){
alert("xxoo");
});

解决方案 »

  1.   

    $("#jsOpenLogin").bind("click",function(){
    alert("xxoo");
    return false;
    });
      

  2.   

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="gb2312" />
    <title></title>
    <style>
    </style>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    </head>
    <body>
    <a href="http://www.baidu.com">123</a>
    <script>
    $('a').bind('click', function(){
    alert(123);
    return false;
    })
    </script>
    </body>
    </html>
      

  3.   

    谢谢。
    在HEAD头部引用JS中需要加$(document).ready(function(){
    这个问题。郁闷