gpt4 book ai didi

php - 如何使用 PHP 函数调用在 DIV 上执行的函数?

转载 作者:行者123 更新时间:2023-12-02 18:40:11 25 4
gpt4 key购买 nike

这是我的代码:

<?php
if (isset($_GET["add"]))
{
?>

<script type="text/javascript" language="javascript">
var i=0;

function createDiv()
{
$('#newdiv').append('<div id="div"'+i+'" class="ex" style="text-align: left;">Life Really suck</div>');

i++;

$( ".ex" ).draggable({containment:'parent',cursor:'pointer',opacity:0.6});
$( ".ex" ).droppable();

}

createDiv(); // will execute when it loads this line
</script>

<?php
}
?>

<div id = "newdiv"> </div>

如何让函数在条件语句之外的 DIV 中执行?

我需要函数正常执行是设置了 GET["add"]

现在,即使该函数确实运行,它也不会在 DIV 中执行

最佳答案

$(document).ready(function(){}) 包围你的 createDiv() 调用,这只会在页面完全加载后执行里面的内容已加载。

关于php - 如何使用 PHP 函数调用在 DIV 上执行的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16912639/

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