【问题标题】:jquery .submit() not triggering though am using $(document).delegate()jquery .submit() 没有触发虽然我正在使用 $(document).delegate()
【发布时间】:2012-11-22 10:16:30
【问题描述】:
 <div class="sld_dwn">
 <form class="sign_in_form" id='target'>
 <div>
 <a class="sign_in_data" >email:</a>
 </br>
 <input type="text" class="sign_in_box" name='txt1'>
 <a class="sign_in_data1">password:</a>
 </br>
 <input type="password" class="sign_in_box1"name='txt2' >
 </div>
 <a href='http://localhost' class="forgot">forgot password</a></br>
 <!--<input type="checkbox"><a class="stay">stay signin</a>-->
 <input type='submit' class="but_signin1" value='Sign in'>
 </form>


包含 jquery 代码的文件是 sginin.js,我正在尝试从 http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js
$("document").ready(function() { $("document").delegate('#target','submit',function(e) { alert('hi'); return false;
给上述 div 的样式是
div.sld_dwn { position:relative; border-radius:0px; display:none; float:right; right:40px; background-color:#3E003E; background-color:RGBA(255, 255, 255,0.2); color:white; border:0px; width:450px; height:120px; }

【问题讨论】:

标签: jquery


【解决方案1】:

这不是选择文档就绪处理程序的方式,应该是这样的:

$(document).ready(function() { 
//^------^--------------------------------remove the quotes and see if works
       $(document).delegate('#target','submit',function(e) { 
//  ----^-------^------------------------------------------------and this one too
          alert('hi'); 
          return false;
       });
 });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-26
    • 1970-01-01
    相关资源
    最近更新 更多