gpt4 book ai didi

javascript - 模态不在 href 上打开

转载 作者:行者123 更新时间:2023-11-30 19:35:53 28 4
gpt4 key购买 nike

当我点击a href=....(特权一)时,它应该打开模式,但它没有打开。虽然 URL 栏更改为 project/index.php#privilege_10

$(document).ready(function() {

$(window.location.hash).modal('show');

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<a href="#privilege_10" class="btn btn-lg btn-dark">Privilege</a>

<!-- The Modal -->
<div class="modal" id="privilege_10">
<div class="modal-dialog">
<div class="modal-content">

<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Privilege Settings for
<font color="blue">Name</font>
</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>

<!-- Modal body -->
<div class="modal-body">
<form method="post" action="/jainvidhya/subdomains/teacher/teacher.php?id=10">
<span class="float-right">Quiz Settings&nbsp;&nbsp;
<input type="checkbox" name="Privilege_Quiz_Name" id="Privilege_Quiz_Id" value="Y"checked='checked'/></span>
<br />
<span class="float-right">Question Settings&nbsp;&nbsp;
<input type="checkbox" name="Privilege_Question_Name" id="Privilege_Question_Id" value="Privilege_Question_Value"checked='checked'/></span>
<br />
<span class="float-right">Student Settings&nbsp;&nbsp;
<input type="checkbox" name="Privilege_Student_Name" id="Privilege_Student_Id" value="Y"checked='checked'/></span>
</div>

<!-- Modal footer -->
<div class="modal-footer">
<input type="submit" class="btn btn-lg btn-info" name="submit" value="Submit">
</form>
</div>

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


<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

当我点击a href=....(特权一)时,它应该打开模式,但它没有打开。虽然 URL 栏更改为 project/index.php#privilege_10

最佳答案

Walks's的帮助下 comment 添加 data-toggle="modal"data-target="#privilege_10" 属性到 a 标签解决了这个问题。

$(document).ready(function() {

$(window.location.hash).modal('show');

});
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<a href="#privilege_10" class="btn btn-lg btn-dark" data-toggle="modal" data-target="#privilege_10">Privilege</a>

<!-- The Modal -->
<div class="modal" id="privilege_10">
<div class="modal-dialog">
<div class="modal-content">

<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Privilege Settings for
<font color="blue">Name</font>
</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>

<!-- Modal body -->
<div class="modal-body">
<form method="post" action="/jainvidhya/subdomains/teacher/teacher.php?id=10">
<span class="float-right">Quiz Settings&nbsp;&nbsp;
<input type="checkbox" name="Privilege_Quiz_Name" id="Privilege_Quiz_Id" value="Y"checked='checked'/></span>
<br />
<span class="float-right">Question Settings&nbsp;&nbsp;
<input type="checkbox" name="Privilege_Question_Name" id="Privilege_Question_Id" value="Privilege_Question_Value"checked='checked'/></span>
<br />
<span class="float-right">Student Settings&nbsp;&nbsp;
<input type="checkbox" name="Privilege_Student_Name" id="Privilege_Student_Id" value="Y"checked='checked'/></span>
</div>

<!-- Modal footer -->
<div class="modal-footer">
<input type="submit" class="btn btn-lg btn-info" name="submit" value="Submit">
</form>
</div>

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


<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

关于javascript - 模态不在 href 上打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55952865/

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