如何在悬停Google Plus One按钮时更改光标样式

时间:2011-09-02 12:13:00

标签: javascript cursor google-plus-one

我想在用户悬停Google“+1”按钮时更改光标样式。 我尝试使用div标记并添加style属性,但它无效。

<div class="g-plusone" data-size="tall" style="cursor:wait" ></div>
<script type="text/javascript">
 (function() {
var po = document.createElement('script'); 
po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; 
s.parentNode.insertBefore(po, s);
})();
</script>

我想我们需要在他们的js代码中添加一些内容。

1 个答案:

答案 0 :(得分:2)

+1是包含这些类的按钮:class="esw eswd",当悬停时,这些:class="esw eswd eswh"。你可以用jQuery获取这个元素并控制它: 例如:

// with jQuery:
$("button.esw.eswd").each(function(){
    $(this).hover(function(){
        // your mouseover code here:
        $(this).addClass("some-class");
    },function(){
        // your mouseout code here:
        $(this).removeClass("some-class");
    });
});

///////////////
// or with css:

button.esw.eswd{
    // mouseout style here
}
button.esw.eswd.eswh{
    // mouseover style here
    cursor:wait;
}
相关问题