Popup onclick Javascript无效

时间:2013-11-18 13:59:58

标签: javascript popup popupwindow

我正在构建一个表单,通过单击文本/图像将其加载到弹出窗口中。这是我的代码,它无法正常工作!任何想法

<div>
<a href="?remind_me" id="remindmelink" onclick="">Remind me</a>
</div>

<div class="map-popup" id="remindme" style="display:none;">
<form>
    <label for="remind_me_email" class="required"><em>*</em>E-Mail Address</label>
    <div class="input-box">
        <input type="text" id="remind_me_email" title="E-Mail Address" />
    </div>
</form>
<div>
    <button type="submit" class="button" id="remind_me_submit"><span>Submit</span>       </button>
</div>
</div>

<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#remindmelink').click(function(){
e.preventDefault();
jQuery('#remindme').dialog('open');
return false;
});
});
</script>

5 个答案:

答案 0 :(得分:0)

$(document).ready(function(){
//open popup
var myPoplink = document.getElementById('remindmelink');
$(myPoplink).on('click',function(){
alert('Hello!'); // to be replaced with $('#remindme').dialog('open');
});
});

答案 1 :(得分:0)

你可以试试这个:

$(document).on('click','#remindmelink',function(e){
   e.preventDefault();
   alert('Hello!'); // to be replaced with $('#remindme').dialog('open');
});

<强>更新

jQuery(document).ready(function(){
  jQuery('#remindmelink').click(function(){
    e.preventDefault();
    jQuery('#remindme').show();
    jQuery('#remindme').dialog('open');
    return false;
  });
});

DEMO

答案 2 :(得分:0)

无效的$('.myPoplink')选择器。即HTML中没有找到类.myPoplink。尝试使用$('#remindmelink')

$(document).ready(function(){
  //open popup  
  $("#remindmelink").on('click',function(event){
      event.preventDefault();
      alert('Hello!'); // to be replaced with $('#remindme').dialog('open');

  });
});

答案 3 :(得分:0)

以防万一href="#"放在这里 jsfiddle

$(document).ready(function(){
    //open popup

      $(document).on('click','#remindmelink',function(){
       alert('Hello!'); // to be replaced with $('#remindme').dialog('open');
       return false;
      });

    });

答案 4 :(得分:0)

这是jQuery冲突,因为一些javascript被内联复制到其他一些页面!通过删除内联脚本并使用

解决
var j = jQuery.noConlifct();
j(document).ready(function(){
j('#remindmelink').click(function(){
j('#remindme').fancybox();
});
});