jQuery不会将内容加载到DIV区域..我哪里出错了 [英] Jquery won't load content into the DIV area .. where did I go wrong

查看:96
本文介绍了jQuery不会将内容加载到DIV区域..我哪里出错了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,所以我尝试使用JQUERY LOAD方法从另一个页面加载内容,因此内容可以在不刷新页面的情况下显示...我这样做了,但是当我单击链接时,它仍然将我重定向到另一个页面页面,而不是将内容加载到div中.

Ok , so I am trying to load content from a another page using JQUERY LOAD method SO THE content can appear without the page refreshing ... I did that but when I click on the link , it still redirects me to the other page instead of the content loading into the div.

下面是我的代码..

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title> MadScore, A Social Scoring Platform </title>
<link rel="stylesheet" type="text/css" href="css/madscore.css">
<link rel="stylesheet" type="text/css" href="css/skins/tango/skin.css" />
<script type="text/javascript" src="javascript/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="javascript/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="javascript/jquery.jcarousel.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        scroll: 1, buttonNextHTML:"<div></div>", buttonPrevHTML:"<div></div>"
    });
});
</script>


//Here is where I made the Jquery call for the div below with class "panel" but it won't load ..

<scrip type="text/javascript">
$(document).ready(function(){
  $("profile").click(function(){
    $(".panel").load("this.href");
  });
});
</script>
</head>

<body>
<div class="sliding-panel">
<div class="container">
<ul id="mycarousel" class="jcarousel-skin-tango">
<li>

<li>
<div class="panel"> //panel supposed to be triggered by Jquery
<h1> People </h1>
<?php
 database_connect();
$query = "select * from People";
$result = $connection->query($query);
$row_count =$result->num_rows;

for($i = 1; $i <= $row_count; $i++)
  {
   $row = $result->fetch_assoc();
    echo "<a href='/profile.php?id=".$row['ID']."' id='profile'><img src ='../".$row['Picture']."' width='100' height='100' /> </a>";

  }


?>
</div>
</li>
</ul>

推荐答案

绑定点击事件时,您缺少#

You are missing # while binding click event

$(document).ready(function(){
  $("#profile").click(function(){  // add # here
    $(".panel").load("this.href");
  });
}); 

还使用 .on 将事件绑定到动态添加的元素.

Also use .on to bind event to dynamically added elements.

这篇关于jQuery不会将内容加载到DIV区域..我哪里出错了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆