php中的jQuery prepend()函数替换
我想将jQuery的任务切换到PHP 早些时候是这样的:php中的jQuery prepend()函数替换,php,jquery,Php,Jquery,我想将jQuery的任务切换到PHP 早些时候是这样的: myString += "Hello There ! "; $("#latestRoutes").prepend(myString).slideDown(2000); 但现在,当我切换到PHP时,如何在PHP中使用$.prepend函数将变量附加到特定字符串?在页面加载时,如果变量设置为,则将其显示为div的第一个子项,如下所示: <div> <?php if(isset($mystring)) echo '
myString += "Hello There ! ";
$("#latestRoutes").prepend(myString).slideDown(2000);
但现在,当我切换到PHP时,如何在PHP中使用$.prepend函数将变量附加到特定字符串?在页面加载时,如果变量设置为,则将其显示为div的第一个子项,如下所示:
<div>
<?php if(isset($mystring)) echo '<p class="test">'.$mystring.'</p>'; ?>
<p>...</p>
<p>...</p>
</div>
$mystring.='Your data'代码>在phpNo中。我试过这个。但是我只想把它附加到一个特定的div中。在页面中查找生成latestRoutes
元素的位置,并将文本添加到它的开头。(当然,slideDown
部分不能在服务器端完成。)除非您正在使用,否则服务器上没有DOM,因此无法像在客户端那样操作它。但那很好,首先修改生成元素的部分。你是说echo?如果我想在循环中添加东西呢。那怎么办?我不明白为什么要投否决票。这是一个合理的问题。你们想要问题本身的答案吗?呵呵?
if($('.test').length > 0) {
alert("This message is brought by php, great!!!");
$('.test').on('click', function(){
$(this).hide();
});
}