本文共 2053 字,大约阅读时间需要 6 分钟。
show([speed,[easing],[fn]])
speed:动画的速度,支持预定义值“slow”、“normal”、“fast”或时间毫秒数值。 ② easing:指定切换效果,默认为“swing”,可选“linear”。 ③ fn:动画完成时执行的函数,每个元素执行一次。hide([speed,[easing],[fn]])
toggle([speed],[easing],[fn])
slideDown([speed],[easing],[fn])slideUp([speed],[easing],[fn])slideToggle([speed],[easing],[fn])fadeIn([speed],[easing],[fn])fadeOut([speed],[easing],[fn])fadeToggle([speed],[easing],[fn])for 循环: for(初始化值;循环结束条件;步长) { // 代码} each() var citys = $("#city li");citys.each(function() { alert(this.innerHTML);}); each() 索引版本 citys.each(function(index, element) { alert(index + ":" + $(element).html());}); for...of(JQuery 3.0 及以上) for(li of citys) { alert($(li).html());} $("#name").click(function() { alert("我被点击了...");}); $("#name").mouseover(function() { alert("鼠标来了...");}).mouseout(function() { alert("鼠标走了...");}); on() 和 off() $("#btn").on("click", function() { alert("我被点击了...");});$("#btn2").click(function() { $("#btn").off();}); $("#btn").toggle(function() { alert("第一点击...");}, function() { alert("第二点击...");}); toggle() 方法已移除,需使用 jQuery Migrate 插件恢复。$(function() { setTimeout(adShow, 3000); setTimeout(adHide, 8000);});function adShow() { $("#ad").show("slow");}function adHide() { $("#ad").hide("slow");} $(function() { var imgs = ["../img/man00.jpg", ..., "../img/man06.jpg"]; var startId; var index; $("#startID").click(function() { startId = setInterval(() => { index = Math.floor(Math.random() * 7); $("#img1ID").prop("src", imgs[index]); }, 20); }); $("#stopID").click(function() { clearInterval(startId); $("#img2ID").prop("src", imgs[index]).show(1000); });}); 以上内容优化后更符合技术写作风格,去除了不必要的外部链接和图片标签,适合搜索引擎优化,并保留了关键的技术细节。
转载地址:http://eqja.baihongyu.com/