简体   繁体   English

更改 hover 上的 Paypal 捐赠按钮

[英]Change Paypal donation button on hover

I made a Paypal donation button at the PayPal page with a custom image.我在 PayPal 页面上使用自定义图像制作了 Paypal 捐赠按钮。 Is there any chance that the image changes the color or different image on hover?图像是否有可能改变 hover 上的颜色或不同的图像?

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
  <input type="hidden" name="cmd" value="_s-xclick" />
  <input type="hidden" name="hosted_button_id" value="RX3MLKWPQBLSN" />
  <input type="image" src="https://domain.sk/paypal2.png" border="0" name="submit" title="PayPal - The 
safer, easier way to pay online!" alt="Donate with PayPal button" />
  <img alt="" border="0" src="https://www.paypal.com/en_SK/i/scr/pixel.gif" width="1" height="1" />
</form>

The CSS method will only let you manipulate the image that you already have and is the method that will use the least resource. CSS 方法只会让您操作已有的图像,并且是使用最少资源的方法。

.paypal_button:hover {
  filter: contrast(50%);
}

jQuery is a lot heavier, but using jQuery you can swap out the image using mouseover and mouseout. jQuery 要重得多,但是使用 jQuery 您可以使用 mouseover 和 mouseout 交换图像。 (I've used a placeholder image to show the example here). (我使用占位符图像来显示此处的示例)。 This will give you the most freedom in replacing the image source to whatever you want when someone hovers.当有人悬停时,这将使您最自由地将图像源替换为您想要的任何内容。

 $( ".paypal_button" ).mouseover(function() { $( this ).attr("src","https://dummyimage.com/qvga/000000"); }); $( ".paypal_button" ).mouseout(function() { $( this ).attr("src","https://dummyimage.com/qvga"); });
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> <input type="hidden" name="cmd" value="_s-xclick" /> <input type="hidden" name="hosted_button_id" value="RX3MLKWPQBLSN" /> <input type="image" class="paypal_button" src="https://dummyimage.com/qvga" border="0" name="submit" title="PayPal - The safer, easier way to pay online:" alt="Donate with PayPal button" /> <img alt="" border="0" src="https.//www.paypal.com/en_SK/i/scr/pixel.gif" width="1" height="1" /> </form>

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

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