Sta*_*arx 1 javascript jquery jquery-selectors
我的HTML是这样的
<div id="mydiv" class="common">
<input type="text" id="text1" value="" />
<input type="text" id="text2" value="" />
</div>
Run Code Online (Sandbox Code Playgroud)
我正在像这样在文本框的onclick事件上分配一个函数
$(document).ready(function() {
$(".common input").click(function() {
//////// What I am trying to do is access the id of its parent
// in this case it is "mydiv"
alert($(this:parent).attr('id'));
});
Run Code Online (Sandbox Code Playgroud)
但它没有用
| 归档时间: |
|
| 查看次数: |
236 次 |
| 最近记录: |