jQuery
2017-01-23 14:50:45 28 举报
AI智能生成
登录查看完整内容
jQuery
作者其他创作
大纲/内容
jQuery HTML
获取内容
$(\"#test\").text();
$(\"#test\").html();
$(\"#test\").val();
获取属性
$(“#test”).attr(\"href\");
设置内容
$(\"#test1\").text(\"Hello world!\");
$(\"#test2\").html(\"<b>Hello world!</b>\");
$(\"#test3\").val(\"Dolly Duck\");
设置属性
$(\"#w3s\").attr(\"href\
添加
$(\"p\").append(\"Some appended text.\");
$(\"p\").prepend(\"Some prepended text.\");
$(\"img\").after(\"Some text after\");
$(\"img\").before(\"Some text before\");
删除元素
$(\"p\").remove(\".italic\");
$(\"#div1\").empty();
jQuery CSS方法
$(\"p\").css({\"background-color\":\"yellow\
遍历
祖先
$(\"span\").parent();
$(\"span\").parents(\"ul\");
$(\"span\").parentsUntil(\"div\");
后代
$(\"div\").children(\"p.1\");
$(\"div\").find(\"span\");
同胞
$(\"h2\").siblings(\"p\");
$(\"h2\").next();
$(\"h2\").nextAll();
$(\"h2\").nextUntil(\"h6\");
p class=\"p1\
过滤
$(\"div p\").first();
$(\"div p\").last();
$(\"p\").eq(1);
$(\"p\").filter(\".intro\");
$(\"p\").not(\".intro\");
事件
鼠标事件
click
dbclick
mouseenter
mouseleave
mousemove
hover
键盘事件
keydown
keyup
keypress
其他事件
focus
blur
change
submit
jQuery
document.ready
action
在head中放置单独的JS脚本
效果
隐藏/显示
淡入淡出
滑动
动画
队列功能
编写多个 animate() 调用
停止
回调函数Callback
Callback 函数在当前动画 100% 完成之后执行
chaining
$(\"#p1\").css(\"color\
选取
元素
$(\"p\").hide()
class
$(\".test\").hide()
id
$(\"#test\").hide()
0 条评论
回复 删除
下一页