请原谅我的无知,但我一直在寻找这个,我无法弄清楚如何更改以下的href:
<a id="p2749244"class="nohover"onfocus="this.blur()"name="index"rel="history"onmouseout="this.className='nohover';"onmouseover="this.className='hover';"href="address">
Run Code Online (Sandbox Code Playgroud)
我需要使用什么样的选择器才能做到这一点?提前致谢.
onmouseover="this.href = 'urlHere';"
Run Code Online (Sandbox Code Playgroud)
或者使用jQuery,您可以使用类选择器.
$('.nohover').hover(function(){
this.href = "urlHere";
});
Run Code Online (Sandbox Code Playgroud)
而不是使用内联事件处理使用jQuery来更好地管理它,试试这个.
$('.nohover').hover(function(){
$(this)
.addClass('hover')
.removeClass('nohover')
.attr('href', 'urlHere');
}, function(){
$(this)
.addClass('nohover')
.removeClass('hover');
}).focus(function(){
$(this).blur();
});
Run Code Online (Sandbox Code Playgroud)