标签:io color os ar 使用 div on cti ef
该实例要用到jquery.js,jquery.cookie.js,json2.js库
var obj = new Object();
obj.id = 1;
obj.name = "aaa"‘
var objStr = JSON.stringify(obj);
$.cookie(‘myCookie‘, objStr);
var myCookie = $.cookie(‘myCookie‘);
var newObj = JSON.parse(myCookie);
$("#select1").change(function() {
var checkText = $(this).find("option:selected").text();
var checkValue = $(this).val();
var checkIndex = $(this).get(0).selectedIndex;
var maxIndex = $("#select1 option:last").attr("index");
});
$("#id").width();
$("#id").css("width");
$("#id").attr("width");
$("#id").attr("disabled", "true");//添加
$("#id").removeAttr("disabled");//移除
var txt = $(‘<input type="text" />‘);
txt.val("hello");
txt.appendTo($div).focus().select().css({"color": "red"});
txt.keyup(function(ev) {//按键up
var e = ev || window.event;
var key = e.keyCode;
if (key == 13) {
alert(key);
$(this).remove();
}
});
txt.blur(function() {//失去焦点
//todo
});
//获得绝对坐标:
var x = $("#id").offset().left;
var y = $("#id").offset().top;
//获得相对(父元素)坐标:
var x1 = $("#id").position().left;
var y1 = $("#id").position().top;
//获得鼠标位置坐标:
$("#div1").mousemove(function(event) {
event = event || window.event;
var x = 0, y = 0;
if (event.pageX || event.pageY) {
x = event.pageX;
y = event.pageY;
}
else {
x = event.clientX + document.body.scrollLeft - document.body.clientLeft;
y = event.clientY + document.body.scrollTop - document.body.clientTop;
}
});
//jquery对象转成DOM对象
var $obj = $("#id");
var obj = $obj[0];//$obj.get(0);
//DOM对象转成jquery对象
var obj = document.getElementById("id");
var $obj = $(obj);
标签:io color os ar 使用 div on cti ef
原文地址:http://www.cnblogs.com/feilv/p/4065037.html