这是我的代码:
<?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/