简体   繁体   English

jQuery打开与类的链接

[英]jquery opening a link with a class

I am using a third party payment system that opens up a small popup that allows the user to enter their details. 我正在使用第三方支付系统,该系统打开一个小的弹出窗口,允许用户输入其详细信息。

I can see that they are using fancybox but cannot edit their js or css. 我可以看到他们正在使用fancybox,但无法编辑其js或css。

I have a current setup that uses jquery that creates steps that guide the user through the various payment options and platforms i use. 我有一个使用jquery的当前设置,该创建的步骤可指导用户逐步了解我使用的各种付款方式和平台。

At the moment the other payment platforms being used open a new page. 目前,正在使用的其他支付平台将打开一个新页面。 I want this one platform to open the fancybox. 我希望这个平台可以打开fancybox。 I am able to link to it with jquery (it switches the link based on the amount). 我可以用jquery链接到它(它根据数量切换链接)。

My issue is that I need to inlude a class thats normally in the tags, using location.href I cant seem to keep this class which opens the overlay rather than a new window. 我的问题是,我需要使用location.href包含通常在标签中的类,而我似乎无法保留此类来打开覆盖而不是新窗口。

so currently: 所以目前:

r += (r.indexOf('?') > -1 ? '&' : '?') + 'amount=' + $('#plus_amount').val()
location.href = r;

Opens as new page 打开为新页面

What i need: 我需要的:

<a class="payment-widget" href="payment link">

Is there any way to open a link with jquery and have it use a class as well? 有什么办法可以打开与jquery的链接并使它也使用一个类?

Thanks in advance 提前致谢

Nad 纳德

I'm not sure what you mean by "open a link using a class", but you can open fancybox manually instead of using location.href : 我不确定“使用类打开链接”是什么意思,但是您可以手动打开fancybox而不是使用location.href

$.fancybox.open({
    href : r,
    title : 'Title'
},{
    //options
});

Demo: http://jsfiddle.net/HK29L/ 演示: http : //jsfiddle.net/HK29L/

Or if you want to assign the href to the anchor: 或者,如果您要将href分配给锚,请执行以下操作:

$('.payment-widget').attr('href', r);

(and then you can trigger a click if you like). (然后您可以根据需要触发点击)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM