jQuery选择器

来源:互联网 发布:易奇八字准不准知乎 编辑:程序博客网 时间:2024/06/05 22:39

jQuery选择器

  • ID #
  • Class .
  • 标签 标签名
  • find('选择器') 在一定的DOM范围中选择

属性方法

  • attr() : 设置DOM属性
  • addClass() : 添加样式
  • html() :
1
$("#adiv").html("<input type='button' value='btn'/>"); // 添加一个按钮
2
$("#adiv").html(); // 取出adiv中的html代码,返回字符串
  • text() : 只是纯文本,不会解析为html

  • val() : 取表单元素的值,比如input select…

样式处理

css(style, value)

文档方法

append() 
appendTo() 
after() 
before() 
insertAfter() 
insertBefore() 
replaceWith() 
replaceAll() 
empty() 
remove() 
clone()

筛选方法

eq() 
hasClass() 
children() 
find() 
parent()

事件

ready() 
on() : 通用的时间处理函数 
blur() : 失去焦点时间 
click() 
change():最多用于select元素

效果

show() 
hide() 
toggle()

[========]

原创粉丝点击