gpt4 book ai didi

php - 在 jquery php 中打开一个 url

转载 作者:行者123 更新时间:2023-12-01 06:14:12 24 4
gpt4 key购买 nike

当我单击“单击此处”时,必须在内部打开一个页面

<script....>
$('yahoo').html('<a href=desc.php>');
</script>

<div id='yahoo'></div>
<div id='clickhere'>Click here</div>

谢谢戴夫

最佳答案

我认为您正在寻找 AJAX 来为您获取页面。像这样的东西可能会起作用:

<script type="text/javascript">
$(function() {
$('#clickhere').click(function() {
$('#yahoo').load('desc.php');
});
});
</script>

<div id='yahoo'></div>
<div id='clickhere'>Click here</div>

首先,您需要将脚本包装在 $(function() { ... }) 中,以便在页面加载时执行代码。这相当于 $(document).ready(function() { ... })

接下来,您必须将单击事件绑定(bind)到 #clickhere 元素,以便您可以在用户单击它时实际执行某些操作。

当用户单击 #clickhere div 时,load()将获取您调用它的元素内给定 url 的内容。因此,此代码段意味着当单击 #clickhere div 时,desc.php 会加载到 #yahoo div 内。

关于php - 在 jquery php 中打开一个 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2135263/

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