Php 如何在每次加载时动态设置div内容?
Home.html 我有一个左菜单,当单击visitor菜单时,它将在名为“rightcont”的div中加载visitor.htmlPhp 如何在每次加载时动态设置div内容?,php,jquery,css,Php,Jquery,Css,Home.html 我有一个左菜单,当单击visitor菜单时,它将在名为“rightcont”的div中加载visitor.html $(".rightcont").load("visitor.html"); 此外,单击students菜单时,它将在div rightcont上加载students.html $(".rightcont").load("students.html"); 但是默认情况下,当第一次访问页面时,我在rightcont中加载了welcome.html 我的问题是,当
$(".rightcont").load("visitor.html");
此外,单击students菜单时,它将在div rightcont上加载students.html
$(".rightcont").load("students.html");
但是默认情况下,当第一次访问页面时,我在rightcont中加载了welcome.html
我的问题是,当用户单击网站其他部分中名为STUDENTS的链接时,它会重定向到home.html,其中“rightcont”div显示welcome.html。我需要rightcont来显示students.html
如何根据单击的链接动态更改它使用:
return false;
确保单击链接时不会重定向页面。单击链接时,可以加载div rightcont
$("#students").click(function() {
$(".rightcont").load("students.html");
return false;
});
(你需要在锚定标记中有id=“students”才能使选择器工作)在学生页面的超链接上,链接到students.php?page=students,并将这一段php添加到页面中
if($_get['page'] == "students")
{
?>
<script type="text/javascript">
$(".rightcont").load("students.html");
<script>
<?
}
else
{
<script type="text/javascript">
$(".rightcont").load("visitor.html");
<script>
}
if($\u get['page']==“学生”)
{
?>
$(“.rightcont”).load(“students.html”);
我正要突然问这个问题,大声说“用jQuery!”但我看得出你已经这么做了。你的意思是什么?@Carson MyersI建议你试着更清楚地解释自己,更重要的是,我不会推荐那些试图帮助你的人投反对票。祝你好运。但是学生链接和rightcont位于不同的页面,这是页面………你需要通过一些va可以从源页面进行变量转换,无论是在帖子中还是注入到目标页面中。这应该是可行的,但可以通过将$_get['page']设置为变量,然后基于该变量加载rightcont,使其更加健壮,因此它也适用于访问者或任何其他链接。