可点击的div修改...需要脚本来查找某个类

时间:2016-12-07 04:35:44

标签: javascript jquery

<script type="text/javascript">
jQuery(".post-entry").click(function() {
  window.location = jQuery(this).find("a").attr("href"); 
  return false;
});
</script>

是否可以修改此脚本以查找具有特定类的href链接?原因是这些div中的一些在其中有多个链接。

1 个答案:

答案 0 :(得分:3)

绝对

$('.post-entry').click(function() {
    window.location = $(this).find('a.example-class').attr('href')
    return false;
})

如果你想要一个手形光标,你也需要一些CSS:

.post-entry {
    cursor: pointer;
}
相关问题