Home  >  Article  >  Web Front-end  >  jquery使整个div区域可以点击的方法_jquery

jquery使整个div区域可以点击的方法_jquery

WBOY
WBOYOriginal
2016-05-16 15:52:581064browse

本文实例讲述了jquery使整个div区域可以点击的方法。分享给大家供大家参考。具体分析如下:

这里实现可以让用户点击整个div区域,这段代码会自动查找div里的链接

$(".myBox").click(function(){
   window.location=$(this).find("a").attr("href");
   return false;
});

Reference HTML:

<div class="myBox">
   blah blah blah.
  <a href="http://google.com">link</a>
</div>

希望本文所述对大家的jQuery程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn