Define a href attribute link in twitter bootstrap modal with jQuery

I have a modal with a form and after i submit the form I get a sucess message. with the success message there is a link

Add another registration 

when I try to set this link to point to the current URL

jQuery(document).ready(function(){
    var url = window.location.href;
    jQuery('#register_again').attr('href', url + '&register_again');
});

but it didn’t change the link and still #, it works fine without the modal if I put it as a normal html

As you are getting the success message after submitting a request, i am not sure about how you are handling the page, like rendering a new page or some other way, like ajax request manner.

But here, in your code, you are trying to update the link, while loading the page. So in your case, you can redirect the page, when user clicks on the link, by binding an even to the link.

jQuery(document).ready(function(){
  var url = window.location.href;
  jQuery(document).on('click','#register_again',function(){
    window.location = url + '&register_again';
  });
});

Hope it helps :)

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » Define a href attribute link in twitter bootstrap modal with jQuery

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录