2011-09-02 90 views
0

我想在用户悬停Google“+1”按钮时更改光标样式。 我试图使用div标记并添加style属性,但它不起作用。如何在悬停Google Plus One按钮时更改光标样式

<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代码。

+0

你为什么想要这样做? –

+0

我想通过更改普通光标来吸引用户的注意力 – Constantino

+0

查看加号按钮的选择器并开启:悬停样式光标。 plusselector:hover {} –

回答

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; 
} 
相关问题