使用ajax和jquery更改滑块的内容

发布于 2024-11-27 07:30:55 字数 128 浏览 0 评论 0原文

我必须做以下事情:我在图像滑块下方有一个内容滑块。每当用户在内容滑块的类别之间切换时,图像滑块应该显示另一组图片(我使用 WordPress,所以这是类别的另一个循环),但无需重新加载整个网站。

您知道这方面有什么好的资源吗?

I have to do the following thing: I have a content-slider beneath a image-slider. Everytime the person switches between the categories of the content-slider, the image-slider should show another set of pictures (I work with wordpress, so it's another loop of category) but without reloading the whole site.

Do you know any good resource for that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

莫相离 2024-12-04 07:30:55

类似的东西 -

在你的 php 中将提供图像 -

if($_GET['ajax'] == 1) {
  //echo relevant images;
}

jQuery 代码将是

function sliderMove() {
  //may also need to pass slider id in here so you know what images to get
  $("#picturediv").load("./test.php?ajax=1");
  //OR
  //to customize your call more, you could do
  $.ajax({
   method: "GET",
   url: "./test.php?ajax=1",
   success: function(data) { $("#picturediv").html(data); },
   error: function(err){ Some_Error_Div.innerHTML = err; }
  });
}

Something like -

In you php that will serve up the images -

if($_GET['ajax'] == 1) {
  //echo relevant images;
}

and the jQuery code would be

function sliderMove() {
  //may also need to pass slider id in here so you know what images to get
  $("#picturediv").load("./test.php?ajax=1");
  //OR
  //to customize your call more, you could do
  $.ajax({
   method: "GET",
   url: "./test.php?ajax=1",
   success: function(data) { $("#picturediv").html(data); },
   error: function(err){ Some_Error_Div.innerHTML = err; }
  });
}
镜花水月 2024-12-04 07:30:55

好吧,我会建议一些与上述解决方案不同的东西。扩展 jquery 库,以便您可以使用一堆需要根据滑块级别隐藏/显示的类来初始化它。

该扩展将接受一组不同的类,这些类被赋予您的各个 div

var level= ['.div1','.div2','.div3']

现在根据滑块所在的位置您将隐藏/显示该 div。

因此,如果滑块位于 2,那么您可以执行类似 $(level[2]).show()$(level[1]).hide() 和 $(level[ 3]).hide()

或者您可以使用类似的库: http://nivo.dev7studios.com/#usage

这里有更多:http://vandelaydesign.com/blog/web-development/jquery-image-galleries/

well I would suggest something diffrent from the above solution.. Extend the jquery library so that you can initilize it with a bunch of classes that you need to hide/display depending on the slider level.

The extension will accept an array of different classes that are given to your various divs
say

var level= ['.div1','.div2','.div3']

now based on where the slider is you will hide/show that div.

thus if the slider is at 2 then you do something like $(level[2]).show() and $(level[1]).hide() and $(level[3]).hide()

or you can use a library like: http://nivo.dev7studios.com/#usage

here are some more: http://vandelaydesign.com/blog/web-development/jquery-image-galleries/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文