jQuery基础选择器

136 阅读1分钟

标签选择器

$("h2" )选取所有h2元素

$('h2').css('color','red');

class选择器

$(" .title")选取所有class为title的元素

$('.a').css('background','red');

id选择器 $('#box')选取所有id为box的元素;

$('#box').css('font-size','40px');

$('#box').css({color:'red',background:'green',padding:'10px'})

并集选择器

$('#box,.a,p').css('color','green');

全局选择器

$('*').css('background','red');