我想让这个div点击,并希望使用相同的内部< a>并希望保持内部链接< a>同样(如果禁用JS,则可以访问链接).
- <div id="example">
- <p> some text </p>
- <img src="example.jpg />
- <a href="https://stackoverflow.com"> link </link>
- </div>
我的意思是我需要这样的.
- <div id="example" href="https://stackoverflow.com">
- <p> some text </p>
- <img src="example.jpg />
- <a href="https://stackoverflow.com"> link </link>
- </div>
解决方法
这样的事情应该做
- $('#example').click(function() {
- window.location.href = $('a',this).attr('href');
- });