可点击的块指针
// clickable blocks
$(".product").click(
function () {
window.location = $(this).find('a').attr("href").css("cursor", "pointer");
return false;
});
容器变得可点击,但光标保持不变。为什么 css 选择器不起作用?
// clickable blocks
$(".product").click(
function () {
window.location = $(this).find('a').attr("href").css("cursor", "pointer");
return false;
});
The container is made clickable but the cursor remains the same. Why isn't the css selector working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
代码:
The code:
“.attr”的返回值是属性值,而不是jquery对象。
如果你希望“容器”有一个新的光标,那么也许你想要这样:
The return value from ".attr" is the attribute value, not a jquery object.
If you want the "container" to have a new cursor, then maybe you want this:
您确实要将光标设置在点击块中吗?在我看来,要做你真正想做的事,你需要这个:
编辑:好的,考虑到你只想在包含 a 的事件上设置点击事件:
Do you really want to set the cursor in the click block? It seems to me that to do what you really want, you need this instead:
Edit: OK, taking into account that you only want to set click events on those that contain an a: