让我们说,我有以下代码内框,但不是一个元素:jQuery选择:选择框
<div class="body">
Click me and it will work.
<div class="head">Click me and nothing will happen.</div>
</div>
我想显示“它的工作原理”当您单击.body
股利而不是里面里面.head
div。我怎样才能做到这一点?
有了这个代码,日志显示,即使你点击head
:
<script>
$('.body').click(function(){console.log('it works !');});
</script>