【问题标题】:How to call div id(id="addObjectForm"), if i press the button(Add Row)? [closed]如果我按下按钮(添加行),如何调用 div id(id="addObjectForm")? [关闭]
【发布时间】:2018-01-05 09:56:47
【问题描述】:

如果我按下“添加行”按钮,我必须调用 div id="addObjectForm" 这是我的示例代码。

<div class="row mt" id="addObjectForm">
    <div class="col-sm-1">
        <button type="button" id="addRowButton">Add Row</button>
    </div>
</div>

提前致谢

【问题讨论】:

  • 请提供示例代码
  • “调用 div...”是什么意思?应该怎么办?
  • 这是我的示例代码
  • 你的问题没有任何意义。想想你想问什么,然后编辑你的问题

标签: javascript html


【解决方案1】:

在下面的代码中找到 jQuery....

$('#addRowButton').click(function(e){
  var id = $(this).closest('.mt').attr('id');
  alert('ID : '+id);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="row mt" id="addObjectForm">
    <div class="col-sm-1">
        <button type="button" id="addRowButton">Add Row</button>
    </div>
</div>

【讨论】:

  • 这对我有用。谢谢@Gyandeep Sharma
  • 欢迎您....请标记答案接受...谢谢
猜你喜欢
  • 2013-10-27
  • 1970-01-01
  • 2013-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-07
  • 2012-08-04
相关资源
最近更新 更多