我正在尝试使用 jquery 来防止页面重新加载。我已经完成了整个代码 php ......并且可以正常工作。如果可以,请访问http://www.jonathansconstruction.com/gallery3.php并单击不同的画廊子菜单查看所有类别、厨房等...我正在使用 get 作为变量。但是,我想使用 jquery 来处理 php,因此我不必将其包含到 gallery.php 中,并且还可以防止页面重新加载,因为它会使页面重新启动,这可能会造成混淆。任何帮助将不胜感激谢谢
更新,感谢所有帮助的人:
到目前为止,我在网站上取得了进展,已在帖子顶部编辑了更正的 URL
流沙效果一切正常。但是,放置流沙效果时,Lytebox 不加载。,一开始它加载得很好,但是在按下其中一个菜单以获得流沙效果之后。它停止工作。另外,我想按照http://www.jonathansconstruction.com/gallery.php中的方式设置菜单按钮的样式。我看到 jquery 没有添加和
任何帮助表示赞赏。下面是我目前修改的 script.js 代码
$(document).ready(function(){
var items = $('.photo_show figure'),
itemsByTags = {};
// Looping though all the li items:
items.each(function(i){
var elem = $(this),
tags = elem.data('tags').split(',');
// Adding a data-id attribute. Required by the Quicksand plugin:
elem.attr('data-id',i);
$.each(tags,function(key,value){
// Removing extra whitespace:
value = $.trim(value);
if(!(value in itemsByTags)){
// Create an empty array to hold this item:
itemsByTags[value] = [];
}
// Each item is added to one array per tag:
itemsByTags[value].push(elem);
});
});
// Creating the "Everything" option in the menu:
createList('View All',items);
// Looping though the arrays in itemsByTags:
$.each(itemsByTags,function(k,v){
createList(k,v);
});
$('#gallery_menu nav a').live('click',function(e){
var link = $(this);
link.addClass('current').siblings().removeClass('current');
// Using the Quicksand plugin to animate the li items.
// It uses data('list') defined by our createList function:
$('.photo_show').quicksand(link.data('list').find('figure'), {adjustHeight: 'dynamic'} );
e.preventDefault();
});
$('#gallery_menu nav a:first').click();
function createList(text,items){
// This is a helper function that takes the
// text of a menu button and array of li items
// Creating an empty unordered list:
var ul = $('<ul>',{'class':'hidden'});
$.each(items,function(){
// Creating a copy of each li item
// and adding it to the list:
$(this).clone().appendTo(ul);
});
ul.appendTo('.photo_show');
// Creating a menu item. The unordered list is added
// as a data parameter (available via .data('list'):
var a = $('<a>',{
html: text,
href:'#',
data: {list:ul}
}).appendTo('#gallery_menu nav');
}
});
另一个编辑:
到目前为止一切看起来都很好解决了很多问题,但是,由于某种原因,我在静态 html 上的跨度在加载 jquery 流沙代码时从显示甚至 html 代码中消失了..?? 这是我在网站的 html 部分拥有的代码,由于某种原因没有出现在实时网站上。
<div id="portfolio">
<div class="photo_show"><span>Gallery Pictures</span>
跨度部分没有出现,不知道为什么
我已经解决了最重要的部分。只是移动了 photo_show div 的顶部并编辑了定位...希望最后编辑流沙的 jquery 使我的日历消失,检查,是的,它是一些 jquery 冲突,但不知道是什么导致它..表单验证也不起作用以及......任何帮助表示赞赏!