gpt4 book ai didi

jquery - 我有两个操作链接和一个模式弹出窗口。有什么方法可以知道点击了哪个操作链接

转载 作者:行者123 更新时间:2023-12-01 02:39:01 27 4
gpt4 key购买 nike

<div><a data-toggle="modal" href="#accmodel" data-target="#accmodel" id="addacc">AddAccomodation</a>
<div id=modeldetails1></div>
</div>
<div><a data-toggle="modal" href="#accmodel" data-target="#accmodel" id="addacc2">AddAccomodation</a>
<div id=modeldetails2></div>
</div>

on click of the submit button in the model popup i need to find out which action link triggered the popup so that i could append the details to coressponding div

<div>
<a data-toggle="modal" href="#accmodel" data-target="#accmodel" id="addacc2">AddAccomodation</a>
<div id=modeldetails2></div>
</div>
<div class="modal fade" id="accmodel" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body col-sm-12" id="mbody">
<div class="form-group">
<textarea id="acctext" class="accomodation"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" id="saveaccbtn">Add</button>
</div>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

</div>
</div>
</div>

最佳答案

你可以简单地使用 jquery 来做到这一点

<div><a  href="#accmodel" data-clicked="from link 1" id="addacc">AddAccomodation</a>
<div id="modeldetails1"></div></div>
<div><a href="#accmodel" data-clicked="from link 2" id="addacc2">AddAccomodation</a>
<div id="modeldetails2"></div></div>
<script>
$(document).ready(function(){


$('#addacc').click(function(){
alert($(this).data('clicked'));
$('#accmodel').modal('show');
});

$('#addacc2').click(function(){
alert($(this).data('clicked'));
$('#accmodel').modal('show');
});
});
</script>

关于jquery - 我有两个操作链接和一个模式弹出窗口。有什么方法可以知道点击了哪个操作链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59640185/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com