如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
1 2 3 4 5 6 7 |
$(function(){ alert($) //返回jq对象 alert($()) //返回jq对象 alert($('#box')) //返回jq对象 alert($('#box').css('color','red')) //返回jq对象 }); |
加载模式
1 2 3 4 5 |
$(document).ready(function(){ }); 简写形式: $(function(){ }); |
对象互换(jq —— dom)
1 2 3 4 5 |
$(function(){ alert($('#box')) //返回jq对象 alert(document.getElementByld('box')); //返回原生dom对象 alert($('#box'.get(0))) ////返回原生dom对象 get(节点号) }); |
选择器
1 2 |
$("div").css("color","red") $('a[title=num]').css("color","red") |
过滤选择器
1 2 3 |
alert($('.red').is(function(){ return $(this).attr('title')=='标题'; })); |