[英]Is it possible to add unique 'field' in Supersized plugin?
Im using Supersized jQuery plugin ( http://buildinternet.com/project/supersized/ ) to show my own photos to the visitors. 我正在使用Supersized jQuery插件( http://buildinternet.com/project/supersized/ )向访客显示我自己的照片。 The visitor can purchase every image on the site, so I decided to add a Buy Now button.
访问者可以购买网站上的所有图片,因此我决定添加“ 立即购买”按钮。
I would like to use PayPal for this, and I found an easy solution for that. 我想为此使用PayPal,为此我找到了一个简单的解决方案。 The problem is with the buy now button, because every image has unique price, so I need to change the price parameter in the anchor's href attribute.
问题在于“立即购买”按钮,因为每个图像都有唯一的价格,因此我需要更改锚点href属性中的price参数。 How can I do that?
我怎样才能做到这一点?
Welcome to SO, just a heads up but it's best to include any related code you already have and/or include a Fiddle that replicates you're problem. 欢迎来到SO,只是一个提示,但是最好包括您已经拥有的任何相关代码和/或包括复制您有问题的Fiddle。
If you're looking to add some information to a anchor href attribute then you can do something like the below. 如果您要向锚href属性添加一些信息,则可以执行以下操作。
The price could be included in a data-
attribute on the image. 价格可以包含在图像的
data-
属性中。
<img src="your/image/source.jpg" data-price="100" />
You could then include a click handler to the buy now button that retrieves price from the closest image and then adds it to the href
attribute. 然后,您可以在“立即购买”按钮中包含一个单击处理程序,该处理程序从最近的图像中检索价格,然后将其添加到
href
属性。
$('.buynow').on('click', function(){
//Find closest image
closestImage = $(this).closest('img');
//Get the price
imagePrice = closestImage.data('price');
//Add the price to the href of the .buynow button
$(this).attr('href','http://yourpaypalscreen.com/' + imagePrice + '/etc');
});
Please note this isn't a working solution but an example to get you started. 请注意,这不是一个可行的解决方案,而是一个使您入门的示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.