在 .click() 事件到 .get() 页面上并替换 jquery 中的 .html()
On .click() event to .get() page and replace .html() in jquery
我有div class="contentBlock"
它被视为更新的容器
<div class="contentBlock"></div>
我有一个我写的脚本不起作用:c
$(document).ready(function(){
$('.postLink').on('click', function () {
$.get("page.php", function (data) {
$(".contentBlock").html(data);
});
});
});
我有一个锚点 html
<div class="box">
<a class="postLink" "href="#">
<h1 title="Light me up"></h1>
<div class="innerbox">
<figure><img src="http://cpsr-rspc.hc-sc.gc.ca/PR-RP/servlet/ShowImage?photoId=1789" /></figure>
<ul class="categorySelect">
<li class="print"></li>
<li class="video"></li>
<li class="web"></li>
</ul>
</div>
</a>
</div>
page.php
只是一个img
标签和一些洛伦。
我从来没有使用过.get()
我确定我用错了它。此外,我将在哪里为加载.gif添加过渡,并在加载时添加淡入?
<a class="postLink" "href="#">
应该是
<a class="postLink" href="#">
你有一个额外的报价。
$(document).ready(function(){
$(".postLink").on('click', function () {
// load in animation.gif here
$(".contentBlock").load("page.php", function() {
// end loading animation now
});
});
});
在 jQuery 中使用负载正是为了这个目的。
这是用于加载的jQuery文档:http://api.jquery.com/load/
相关文章:
- 如何用javascript替换Jquery字符串上的新参数
- 替换jquery对象中键的值
- 替换jquery中的spanhtml文本
- 替换 jQuery 中锚标记的值
- 替换 jquery 加载的外部 html 文件中的文本
- 在 .click() 事件到 .get() 页面上并替换 jquery 中的 .html()
- 如何使用 ?parameter=only 链接重新加载页面并替换 Jquery Mobile 中的当前锚页面
- 香草 js 替换 jQuery 的 index() 和 eq()
- JavaScript-用Angular代码替换jQuery$
- 用我自己的(措辞?)替换jquery函数
- 使用正则表达式替换Jquery
- 图像悬停并替换-jquery
- 替换jquery's仅在加载DOM功能后运行
- 替换jQuery单击事件上的标题文本
- 如何动态替换jQuery MOBILE中的过滤器搜索栏?
- 动画img替换jquery悬停
- 替换jquery中的多个查找选择器
- 找到,替换jquery..搜索词数组有问题
- Javascript/jsLint:使用“use strict”时用什么替换jQuery(this);
- 用Javascript替换jQuery函数