1.  ---------------

-var aa = new Array();

aa.push(1);

alert(aa[0]);

var aa=[];也表示一个数组;

--------------------------

var a = "sdfsfs";

if (typeof (a) == "string")

alert("shfidfodsf");

else if (typeof (a) == "undefined")

alert("未定义");

-----------------通过构造函数属性来判断类型;分割字符串

var gg = "gu,oze,ng";

var aa = gg.split(",");

if(aa.constructor==Array)

alert(aa[2]);

-------------------归并字符串;

var aa = new Array(1, 2, 3, 4);

var b = aa.join("-");

alert(b);

--------------------------

$(document.body).css("background-color","Red");

---------------------:切记没有分号,px后面,否则无效果;

$("li").each(function () {

$(this).css("background-color", "green");

$(this).css("font-size","20px");

});

--------------

$("li:eq(3)").css("background-color", "red");匹配第四个li;

------------

$("li:contains('b')").css("background-color", "red");内容含有b的标签;

---------------

//$("ul").css("background-color","red");

//$("ul").attr("style", "background-color:red; font-size:20px;");

//$("ul").attr({ style: "background-color:red;",style: "background-color:red;"});

$("ul").attr("class", "lii");

$("ul").removeAttr("class");

-------------------------

$("p").addClass("selected highlight");

------------------获得索引:

.index();从0开始,返回一个数字;

-----------有的话,删除,没有的话添加;

$("ul").click(function () {

$(this).toggleClass("lii");

});

--------------not:除此之外的;

$("li").not($("li:last")).css("background-color", "red");

-------------2,3只选择第三个,2,4只选择第三和第四个,索引从0开始;当slice(2),表示从第三个到最后一个;

$("li").slice(2,3).css("background-color", "red");

---------------------lt:前四个;

$("li:gt(4)").css("background-color", "red");

-------所有的li;

$("ul").children().css("background-color", "red");

--------class为dd的类;

$("ul").children(".dd").css("background-color", "red");

-------------所有的同级元素;

$("#f").nextAll().css("background-color", "red");

-----------挨着的第一个同级元素;

$("#f").next().css("background-color", "red");

-----------同级直到table标记之间的同级标记,不包括table;

$("#f").nextUntil("table").css("background-color", "red");

-------------找到所有父级的标记;

$("#nei").parents().css("background-color","red");

-------------应该只有上一级;

$("#nei").parent().css("background-color","red");

-------------

siblings:除此之外的所同级元素;

---------相当于累加;

$("#nei").add("table").add("#f").css("background-color","red");

-----------并把自己也加上;

$("div").find("p").andSelf().addClass("border");

--------------将所有元素添加到b标签中;

$("#nei").contents().wrap("<b/>");

-------------在p标签的前面添加标记;append是后面;

$("p").prepend("<b>Hello</b>");

--------------.after,.before,insertafter,insertbefore;

------------将元素包含到另一元素中;

$("p").wrap(document.getElementById('content'));

------------

将所有匹配的元素用单个元素包裹起来时使用wrapall();

---------------------------:在p的内部添加b;(将p的内容用b抱起来)

$("p").wrapInner("<b></b>");

-----------变换标记;

$("p").click(function () {

$(this).replaceWith("<img src='../img/_8-1.png'></img>");

-----------

});

---------------------复制一份添加到标记中

$("b").clone().prependTo("p");

---------------------

将所有段落的字体颜色设为红色并且背景为蓝色。

jQuery 代码:

$("p").css({ color: "#ff0011", background: "blue" });描述:

如果属性名包含 "-"的话,必须使用引号:

jQuery 代码:

$("p").css({ "margin-left": "10px", "background-color": "blue" });

-----------------------不管怎么样:键值都加双引号;

$("#f").css({"color":"red","background":"blue"});

----------------------------------------------------------offset相对document的位置;

-----------设定移量;

$("#xuan").offset({top:200,left:400});

-------------得到相对位置

var a = $("#xuan").offset();

alert(a.left+"----"+a.top);

--------------------------------------------------------------position(),相对于父元素的偏移量;用法和offset一样;

------blur():失去焦点触发的事件;

-----change()事件:当内容改变且失去焦点时触发;

-------------滚动条滚动

$(window).scroll(function () {

setTimeout();

$("#xuan").offset({ top: $(window).scrollTop() + 200 });

});

-----------序列化操作:

var a = $.parseJSON('{ "name": "guozeng" }');

alert(a.name);

---------------------

------------------------textbox下拉框案例

$(function () {

$("#Text1").focus(function () {

//$("#gg").attr("display","block");

$("#gg").css("display", "block");

$("#gg").offset({ top: $("#Text1").offset().top + $("#Text1").height() + 5, left: $("#Text1").offset().left });

});

$("li").click(function () {

$("#Text1").val($(this).text());

$("#gg").css("display", "none");

});

})

-------------------pannel案例:

$(function () {

$("img[alt='a']").click(function () {

if ($(this).attr("src") == "../img/_8-1.png") {

$(this).attr("src", "../img/_8-2.png")

$("#gg").slideUp(500);

}

else {

$(this).attr("src", "../img/_8-1.png")

$("#gg").slideDown(500);

}

});

})

---------------------------

最新文章

  1. web网站获取客户端mac地址
  2. 【动态规划】bzoj1663 [Usaco2006 Open]赶集
  3. perl push an array to hash
  4. R 绘图 填充颜色
  5. shiro的简单使用
  6. Server asks us to fall back to SIMPLE auth, but this client is configured to only allow secure connections.
  7. Data truncation: Truncated incorrect DOUBLE value 解决方案
  8. GoldenGate 之 Bounded Recovery说明
  9. Lua 常用的shell命令
  10. 1401 - Remember the Word
  11. 给jdk写注释系列之jdk1.6容器(12)-PriorityQueue源码解析
  12. 关于 width;height
  13. Ubuntu14.04安装wineqq国际版出现无法输入中文的解决方法
  14. MVC之联动学习
  15. ROS_Kinetic_21 使用Qt Creator Plug in即ros_qtc_plugin
  16. 使用gradle命令代替CUBA Studio,启动项目
  17. 自己总结的C#编码规范--1.命名约定篇
  18. 【Linux】【Jenkins】配置过程中,立即构建时,maven找不到的问题解决方案
  19. 帝国cms搜索关键字调用标签(showsearch)怎么用
  20. flask上下文全局变量,程序上下文、请求上下文、上下文钩子

热门文章

  1. UVA1232 - SKYLINE(段树部分的变化)
  2. JavaScript--基于对象的脚本语言学习笔记(三)
  3. 背包问题 (DP)
  4. React实践
  5. UI測试内容
  6. Win7安装和配置Tigase 5.2server
  7. 经典算法题每日演练——第七题 KMP算法
  8. MessageDigest简要
  9. POJ1201-Intervals(差动限制)
  10. ScrollView 嵌套ListView 幻灯冲突,和显示不全