jquery_1

jqury

1.alt VS title
when your img does not show up,then you will see the alt on the page;
and when mouseover the img,what you see is title;

2.attr()
get arrtibute value: you can use the function attr("attr_name") to access the attribute;
also,you can set the attribute by the reload function attr("attr_name","attr_value");
example:
var txt = $("#myimg").attr("title"); //get the value of attribute title of myimg;
$("p").attr("text",txt); //then set value of title to all the tag <p>‘s text;

3.addClass()
we can add a defined class to the element of DOM by use to addClass() function;

4.css()
we can access the CSS of DOM elements;
like:$("p").css("background-color","yellow");//to set the background of all <p> to yellow;
$("p").css({color:red,background-color:yellow,font-size:16px});//set multiple css items;

5.removeClass();
remove the class of elements;

6.html()
get the html(contents) of elements(which means the innerHTML);

7.eq()
for DOM traversing,jquery have the function eq(index);
like:seek for the third li of ul:$("li").eq(2); //careful,the selector is not ul but li;

8.filter(selector)
this function allow you to filter out the elements by selector;
like:$("li").filter(".middle").addClass("selected");
//get all the li,then filter out the class = middle,the set their class to seletes;

9.find(selector);
use this function ,we can find the child elements right in the range we get;
like:$("p").find("span").addClass("selected");
//get all the <p> elements,the find all its <span> children elements;

10.width(value),height(value)
set the width or height of selectors;
like:$("div:first").width(100);//set the first div‘s width to 100;

11.html() VS text()
the function html() alaways mathch the innerHTML of the first selector
while the function text() match the innerHTML of all the selectors;

12. dl dt dd;
dictionary list;dictionary theme; dictionary data;

13.replaceWith(content)
replace the innerHTML of selector;
like:$("div").relaceWith("<h1>Hello World!</p>");

14.remove()
remove all the innerHTML of matched selectors;
like:$("div").remove();

15.after(),before();
insert the html after or before the selector;
like:$("div").after("<div class = "myDiv"><p>Hello World!</p></div>");

16.append() VS after()
append() means to append to the selector‘s innerHTML;
while the after() is to insert the selector‘s HTML;

时间: 2024-08-08 04:33:46

jquery_1的相关文章

2016最新Java学习计划

一.Java学习路线图 二.Java学习路线图--视频篇 六大阶段 学完后目标 知识点 配套免费资源(视频+笔 记+源码+模板) 密码        第一阶段 Java基础 入门 学习周期: 35天 学完后目标: 1.可进行小型应用程序开发 2.对数据库进行基本的增删改查管理 市场价值:¥5000 计算机基础知识 计算机基础.DOS常用命令.Java概述.JDK环境安装配置.环境变量配置.Java程序入门 1.2015年Java基础视频-深入浅出精华版(强烈推荐) 2.历经5年锤炼(适合初学者入

js和jq中常见的各种位置距离之offset和offset()的区别(三)

offsetLeft:元素的边框的外边缘距离与已定位的父容器(offsetparent)的左边距离(不包括元素的边框和父容器的边框). offset().left:返回的是相对于当前文档的坐标,使用offset()方法不管该元素如何定位,也不管其父元素如何定位,都是获取的该元素相对于当前窗口的偏移坐标 附上调试代码: 1 <style> 2 *{margin:0;padding:0;} 3 #parent{ position: relative; padding: 10px; margin:3

jsp文件上传

整理了一下jsp的上传下载,由客户端到服务端,包括一些常规的业务 一客户端 先看最基本的情况 1 在表单设置multipart/form-data,通过提交键把数据和附件一次性提交的.服务器更多的是对应这个例子. 但有以下问题 一般的Ajax无法把附件数据发过去 附件往往涉及比较多问题,比如上传需要时间(要有个进度),上传也有可能不成功等,上传需要校验的东西就比较多. 2于是就有把上传分开来自己执行的.上传项在浏览文件后就开始上传,其他表单数据在提交表单时再提交. 更详细地说是:上传在表单中有自

js和jq中常见的各种位置距离之offsetLeft和position().left的区别(四)

offsetLeft:元素的边框的外边缘距离与已定位的父容器(offsetparent)的左边距离(不包括元素的边框和父容器的边框).position().left:使用position().left方法时事实上是把该元素当绝对定位来处理,获取的是该元素相当于最近的一个拥有绝对或者相对定位的父元素的偏移位置. 附上调试代码: 1 <style> 2 *{margin:0;padding:0;} 3 #parent{ position: relative; padding: 10px; marg

jquery星级插件、支持页面中多次使用

我从网上收集一个jquery星级插件的,它只支持一个页面中使用一次,多次使用的话会发生冲突,达不到我项目的需求,没办法,只能修改它, 效果图如下: css所需背景图片:   二话不说,帖代码: html代码 <div class="xing"> <span style="float: left">总体评价:<font color="#CC3300" size="-1">*</font&

如果用HTML5做一个在线视频聊天【原创】

首先使用node.js 搭建一个简易的 websocket服务器: var cons = new Array(); var ws = require('ws').Server; var server = new ws({ port: 8888 }); server.on('connection', function (ws) { console.log('new connection founded successfully'); cons.push(ws); ws.on('message',

jquery追加内容

<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> #content{ width: 300px; height: 300px; padding:10px; background-color: pink; } .base{ background-color: ye

如何用JS和HTML 做一个桌面炒股小插件【原创】

首先,使用node-webkit 做环境,废话不多说,直接贴HTML <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> &

POST &amp;amp; GET &amp;amp; Ajax 全解

GET&POST&Ajax 全解 一.POST和GET的差别 GET:GET方法提交数据不安全,数据置于请求行.客户段地址栏可见:GET方法提交的数据限制大小在255个字符之内.參数直接跟在URL后面清晰可见,该http请求的body部分也是空的.仅仅有head部分显示了一个http的基本信息. POST:POST方法提交的数据置于消息主体内,client不可见,POST提交的数据大小没有限制. POST方式发送的http请求,參数不是跟在URL后面的,而是存放在http请求的body部分