在按钮上的以下代码中,单击父 div 的输入文本会发出警报。我不清楚“使用父 div 范围”是什么意思。有人可以向我解释一下这个范围吗
HTML
<div class="info">
<input type="text" placeholder="Email" class="email" value="a@gmail.com" />
<button class="btn">Click Me</button>
</div>
<div class="info">
<input type="text" placeholder="Email" class="email" value="b@gmail.com" />
<button class="btn">Click Me</button>
</div>
<div class="info">
<input type="text" placeholder="Email" class="email" value="b@gmail.com" />
<button class="btn">Click Me</button>
</div>
<div class="info">
<input type="text" placeholder="Email" class="email" value="d@gmail.com" />
<button class="btn">Click Me</button>
</div>
jQuery
$(document).on('click', '.btn', function () {
var $this = $(this).parents('.info');
var email = $('.email', $this).val();
alert(email);
});