I am building a form which will be loaded in popup by clicking on a text/image. This is my code and it is not working! Any ideas
<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>
$(document).ready(function(){
//open popup
var myPoplink = document.getElementById('remindmelink');
$(myPoplink).on('click',function(){
alert('Hello!'); // to be replaced with $('#remindme').dialog('open');
});
});
You can try this:
$(document).on('click','#remindmelink',function(e){
e.preventDefault();
alert('Hello!'); // to be replaced with $('#remindme').dialog('open');
});
UPDATE :
jQuery(document).ready(function(){
jQuery('#remindmelink').click(function(){
e.preventDefault();
jQuery('#remindme').show();
jQuery('#remindme').dialog('open');
return false;
});
});
invalid $('.myPoplink')
selector. ie there is no class .myPoplink
found in the HTML. Try using $('#remindmelink')
$(document).ready(function(){
//open popup
$("#remindmelink").on('click',function(event){
event.preventDefault();
alert('Hello!'); // to be replaced with $('#remindme').dialog('open');
});
});
Just in case put href="#"
here is the jsfiddle
$(document).ready(function(){
//open popup
$(document).on('click','#remindmelink',function(){
alert('Hello!'); // to be replaced with $('#remindme').dialog('open');
return false;
});
});
It was jQuery conflict as some javascript was copied inline in some other pages! Solved by removing the inline scripts and using
var j = jQuery.noConlifct();
j(document).ready(function(){
j('#remindmelink').click(function(){
j('#remindme').fancybox();
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.