javascript代码实例教程-jquery随机加载xml内容
发布时间:2019-02-14 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了javascript代码实例教程-jquery随机加载xml内容,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。
jquery随机加载XMl内容
演示
X
ML/
HTML Code
-
data.xml
XML/HTML Code-
-
-
-
-
- http://freejs.net/article_fenye_49.html
- http://freejs.net/demo/49/demo.jpg
- Jquery, Ajax无刷新翻页,支持跳转页面
- freejs已经发了不少无刷新翻页的代码了,点击右侧“相关文章”可以找到,这边这个不同在于多了一个跳转页面。
- 数据库与本站其他翻页的相同,本例和《jquery 无刷新翻页》均是非常实用的案例,而且本例更简单易懂
-
-
-
-
- http://freejs.net/article_jiaodiantu_82.html
- http://freejs.net/demo/82/demo.jpg
- 右侧带透明遮罩效果文字简要的jQuery焦点图代码
- css文件请到演示页面查看源码
-
-
-
-
-
- http://freejs.net/article_DAOhangcaidan_67.html
- http://freejs.net/demo/67/demo.jpg
- 类似京东和易迅的菜单-可以折叠隐藏的导航菜单
- 很流行的菜单,很多购物网站在使用,包括京东,新蛋中国,易迅都是类似的
- 演示地址可以存源码
-
-
-
-
- http://freejs.net/article_tabbiaoqian_29.html
- http://freejs.net/demo/29/demo.jpg
- jquery实现简单的Tab切换菜单
- jquery实现简单的Tab切换菜单
-
-
-
-
- http://www.freejs.net
- http://freejs.net/images/LOGo.png
- freejs-Web演示,导航菜单,TAB标签,焦点图,图片特效,分页,表单
- 导航菜单,TAB标签,焦点图,图片特效,分页,表单等各种jquery代码演示
-
-
-
-
readxml.js
JavaScript Code- /*
- Learn How to Read, Parse and Display XML Data in Random Order wITh jQuery
- Author: Kevin Liew
- Website: http://www.queness.COM
- */
-
- XMLLIST = {
-
- //general settings
- xml: 'data.xml?' + Math.random(0,1), //solve ie weird caching issue
- display: '3', //number of items to be displayed
- random: true, //display randomly {true|false}
- apPEndTo: '#list', //set the id/class to insert XML data
-
- init: function () {
-
- //jQuery ajax call to retrieve the XML file
- $.ajax({
- type: "GET",
- url: XMLLIST.xml,
- dataType: "xml",
- success: XMLLIST.parseXML
- });
-
- }, // end: init()
-
- parseXML: function (xml) {
-
- //Grab every single ITEM tags in the XML file
- VAR data = $('item', xml).get();
- //Allow user to toggle display randomly or vice versa
- var list = (XMLLIST.random) ? XMLLIST.randomize(data) : data;
- var i = 1;
-
- //Loop through all the ITEMs
- $(list).each(function () {
-
- //Parse data and embed it with HTML
- XMLLIST.insertHTML($(this));
-
- //If it reached user PRedefined total of display item, stop the loop, job done.
- if (i == XMLLIST.display) return false;
- i++;
- });
-
-
- }, // end: parseXML()
-
- insertHTML: function (item) {
-
- //retrieve each of the data field From ITEM
- var url = item.find('url').text();
- var image = item.find('image').text();
- var title = item.find('title').text();
- var desc = item.find('desc').text();
- var html;
-
- //Embed them into HTML code
- html = '
';
- html += '';
- html += '' + title + '';
- html += '
' + desc + '
'; - html += '';
-
- //Append it to user predefined element
- $(html).appendTo(XMLLIST.appendTo);
-
- }, // end: inserthtml()
-
-
- randomize: function(arr) {
-
- //randomize the data
- //Credit to JSFromHell http://jsfromhell.com/array/shuffle
- for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
- return arr;
-
- } // end: randomize()
-
-
- }
-
- //Run this script
- XMLLIST.init();
原文地址:http://www.freejs.net/article_jquerywenzi_120.html 觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! js脚本,巧夺天工,精雕玉琢。小宝典献丑了!
脚本宝典总结
以上是脚本宝典为你收集整理的javascript代码实例教程-jquery随机加载xml内容全部内容,希望文章能够帮你解决javascript代码实例教程-jquery随机加载xml内容所遇到的问题。
如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。