《JQuery基础教程》第四版课后练习代码--第六章
来源:互联网 发布:java spring框架详解 编辑:程序博客网 时间:2024/05/19 02:04
1、页面加载后,把exercises-content.html的主体(body)内容提取到页面的内容区域
$(document).ready(function () { $("#letter-a a").click(function(event){ event.preventDefault(); $("#dictionary").load('exercises-content.html'); })})
2、不要一次就显示整个文档,请为左侧的字母列表创建“提示条”,当用户鼠标放到字母上时,从exercises-content.html中加载与该字母有关的内容
$(document).ready(function () { $(".letter").mouseover(function(event){ event.preventDefault(); var $text=$(this).text().trim().charAt(0).toLowerCase(); $("#dictionary").load('exercises-content.html #letter-'+$text); })})3、为页面加载添加错误处理功能,在页面的内容区显示错误消息。修改脚本,请求does-not-exsit.html而不是exerises-content.html,以测试错误处理功能。
$(document).ready(function () { $(".letter").mouseover(function(event){ event.preventDefault(); var $text=$(this).text().trim().charAt(0).toLowerCase(); $("#dictionary").load('does-not-exist.html #letter-'+$text,function(response,status,xhr){ if(status=='error'){ $("#dictionary").html("An error occured:"+xhr.status+' '+xhr.statusText); } }) })})4、挑战:页面加载后,向GitHub发送一个JSONP请求,取得某个用户代码库的列表。把每个代码库的名称和URL插入到页面的内容区。取得JQuery项目代码库的URL是:https://api.github.com/users/jquery/repos
$(document).ready(function () { $.getJSON('https://api.github.com/users/jquery/repos',function(data){ var html=''; $.each(data,function(jsonindex,json){ html+="<div>"+(jsonindex+1)+"<br>"; html+="name: "+json.name+"<br>"; html+="url: "+json.html_url+"<br>"; html+="</div>" }) $("#dictionary").html(html); })})
0 0
- 《JQuery基础教程》第四版课后练习代码--第六章
- 《JQuery基础教程》第四版课后练习代码--第四章
- 《JQuery基础教程》第四版课后练习代码--第三章
- 《JQuery基础教程》第四版课后练习代码--第五章
- 学习笔记:《jQuery基础教程》第四版第六章课后练习——通过Ajax发送数据
- 学习笔记:《jQuery基础教程》第四版第二章课后练习
- 学习笔记:《jQuery基础教程》第四版第三章课后练习
- 学习笔记:《jQuery基础教程》第四版第四章课后练习——样式与动画
- 学习笔记:《jQuery基础教程》第四版第五章课后练习——操作DOM
- 《jQuery基础教程》第四版第七章课后练习——使用插件
- 【练习向】jQuery基础教程第四版课后练习——Book02_jQuery_选择元素
- 【练习向】jQuery基础教程第四版课后练习——Book03_jQuery_事件
- 【练习向】jQuery基础教程第四版课后练习——Book04_jQuery_样式与动画
- 【练习向】jQuery基础教程第四版课后练习——Book05_jQuery_操作DOM
- 【练习向】jQuery基础教程第四版课后练习——Book06_jQuery_通过Ajax发送数据
- 【练习向】jQuery基础教程第四版课后练习——Book07_jQuery_使用插件
- 【练习向】jQuery基础教程第四版课后练习——Book08_jQuery_开发插件
- c++primer第五版课后练习答案(第六章)
- 欢迎使用CSDN-markdown编辑器
- [leetcode]167. Two Sum II - Input array is sorted
- python opencv 图像按位操作
- java并发你必须会的编程
- 1029. Median (25)
- 《JQuery基础教程》第四版课后练习代码--第六章
- 精确记算程序的运行时间或者某段代码的运行时间
- Jenkins在windows上安装
- android realm数据库基本使用
- Efficient Gradient-domain Compositing
- tcp sever
- Mysql基础知识----常用命令
- client
- java多线程学习