jQuery基础教程-第6章练习
2013-02-18 13:48
661 查看
06.js
$(document).ready(function(){ var dictionary=$('#dictionary'); //Answer 1 dictionary.load('exercises-content.html .letter'); //Answer 2 $('.letter').mouseenter(function(e){ var letterId=this.id; console.log(letterId); dictionary.load('exercises-content.html #'+letterId); }).mouseleave(function(e){ dictionary.html(''); }); //Answer 3 $('.letter').mouseenter(function(e){ var letterId=this.id; console.log(letterId); dictionary.load('does-not-exist.html #'+letterId, function(response,status,xhr){ if(status == "error"){ dictionary.html('An error occurred: ' + xhr.status) .append(xhr.responseText); } }); }).mouseleave(function(e){ dictionary.html(''); }); //Answer 4 $.getJSON("http://examples.learningjquery.com/jsonp/g.php?callback=?",function(data){ var html=''; $.each(data, function(i,item){ html += '<div class="entry">'; html += '<h3 class="term">'+ item.term + '</h3>'; html += '<h3 class="part">'+ item.part +'</h3>'; html += '<div class="definition">'+ item.definition; if(item.quote){ html +='<div class="quote">'; $.each(item.quote, function(qi,qitem){ html += '<div class="quote-line">'+ qitem +'</div>'; }); html +='</div>'; } if(item.author){ html +='<div class="quote-author">' + item.author +'</div>'; } html += '</div>'; html += '</div>'; }); dictionary.append($(html)); }); });
相关文章推荐
- jQuery基础教程-第5章练习
- jQuery基础教程-第4章练习
- 【练习向】jQuery基础教程第四版课后练习——Book06_jQuery_通过Ajax发送数据
- jQuery基础教程-第3章练习
- 【练习向】jQuery基础教程第四版课后练习——Book03_jQuery_事件
- 【练习向】jQuery基础教程第四版课后练习——Book05_jQuery_操作DOM
- 【练习向】jQuery基础教程第四版课后练习——Book04_jQuery_样式与动画
- 【练习向】jQuery基础教程第四版课后练习——Book02_jQuery_选择元素
- 【练习向】jQuery基础教程第四版课后练习——Book07_jQuery_使用插件
- 【练习向】jQuery基础教程第四版课后练习——Book08_jQuery_开发插件
- Hadoop基础教程-第6章 MapReduce入门(6.1 MapReduce介绍)(草稿)
- Hadoop基础教程-第6章 MapReduce入门(6.2 解读WordCount)(草稿)
- JQuery基础教程:选择元素(上)
- jQuery官方基础教程笔记
- JQuery 常用方法基础教程
- jQuery基础教程之DOM操作-遍历节点-parent()方法
- jQuery基础教程 Pluralsight视频教程 中文字幕
- jQuery 基础教程目录
- php基础教程之综合练习
- jQuery基础教程之 基本选择器