javascript

js 实现支持crtl与shift键的行多选

var lastObj = {}; //选中的当前行对象
var tableObj = {}; //表对象

//按键多选
function onTrClick(o) {
tableObj = document.getElementById(“Table1”);
var len = tableObj.rows.length;
for (var i = 1; i < len; i++) { tableObj.rows[i].rowNum = i; } if (event.ctrlKey) {//如果按下了ctrl键 if (o.style.backgroundColor == "#ffffff") { o.style.backgroundColor = '#e3e9f4'; lastObj = o; }else if (o.style.backgroundColor == "#e3e9f4") { o.style.backgroundColor = '#ffffff'; } }else if (event.shiftKey) {//如果按下了shift键 var beginNum, lastNum; if (lastObj.rowNum <= o.rowNum) { beginNum = lastObj.rowNum; lastNum = o.rowNum; }else { beginNum = o.rowNum; lastNum = lastObj.rowNum; } for (var i = 0; i < len; i++) { if (i >= beginNum && i <= lastNum) { tableObj.rows[i].style.backgroundColor = "#e3e9f4"; }else{ tableObj.rows[i].style.backgroundColor = "#ffffff"; } } lastObj = o; }else { for (var i = 1; i < len; i++) { tableObj.rows[i].style.backgroundColor = "#ffffff"; } o.style.backgroundColor = '#e3e9f4'; lastObj = o; } }


jQuery live() failing with jQuery UI datepicker

I’ve got it to bind to the lightbox’d inputs on the first appearance of the lightbox, but it’s not working afterwards.

I’m doing the following:

$(function() { 
    $('.jQueryCalendar').live('click', function () {
            $(this).datepicker({showOn: 'both'}).focus();
    });
});

When the lightbox closes, I’m re-appending it’s content to the page (in order to not lose the content div), and this seems to be killing the live() call. [NB the re-appending takes place after the original content is destroyed]

EDIT

Ok, the live() event IS firing (thanks to Nick Craver for that), however the datepicker is no longer being shown. Does anyone have an idea why?

EDIT #2

Ok, the use of .html() to re-append causes the events to need rebinding, but the element to bind still has the class hasDatepicker, which messes with the datepicker() initialisation.

To fix, simply user

$(this).removeClass('hasDatepicker') .datepicker({showOn: 'both'}).focus();

 


jQuery.Autocomplete 中文支持

jQuery.Autocomplete是jquery的流行插件,能够很好的实现输入框的自动完成(autocomplete)、建议提示(input suggest)功能,支持ajax数据加载。 (continue reading…)


[jQuery]Drag And Drop Everything With 30 Handy jQuery Plugins

Do you want to become drag and drop feature expert? Then look no further – this article is just for you! Mostly these plugins are written in jQuery,  and they are super easy to customize and implement in your own projects very fast.

Why such plugins are so handy? You can give your visitors a lot more customization options, they can virtually personalize your website or tool to suit it better for their needs. And you must know – people love it, I love it myself!

Ready to drag and drop into this article? (continue reading…)


Location href search hash …

location对象
含有当前URL的信息.
属性
href 整个URL字符串.
protocol 含有URL第一部分的字符串,如http:
host 包含有URL中主机名:端口号部分的字符串.如//www.cenpok.net/server/
hostname 包含URL中主机名的字符串.如http://www.cenpok.net ;
port 包含URL中可能存在的端口号字符串.
pathname URL中”/”以后的部分.如~list/index.htm
hash “#”号(CGI参数)之后的字符串.
search “?”号(CGI参数)之后的字符串.

location对象 含有当前URL的信息. 属性 href 整个URL字符串.  protocol 含有URL第一部分的字符串,如http:  host 包含有URL中主机名:端口号部分的字符串.如//www.cenpok.net/server/  hostname 包含URL中主机名的字符串.如http://www.cenpok.net ; port 包含URL中可能存在的端口号字符串.  pathname URL中”/”以后的部分.如~list/index.htm  hash “#”号(CGI参数)之后的字符串.  search “?”号(CGI参数)之后的字符串.


JavaScript数组去掉重复

引用Ext中实现方法:

Java代码
  1. unique: function( array ) { (continue reading…)

eventKey code

function checkNumber(event,objThis)
{
	var eventKey = document.all ? event.keyCode : event.which;
	if(!(eventKey>=48&&eventKey<=57) && eventKey != 8 )
		return false;
}
<input type="text" size="4" maxlength="4" value="2" name="count" onkeypress="return checkNumber(event,this);">
1 Comment more...

ie6 下 jquery的 submit不起作用

  • 问题:
  • 项目中所有使用jquery.submit()的方法在验证后提交在ie6中失去作用;
  • 所有使用window.location.href=*** 方法在验证后在ie6中失去作用;
  • 所有a链接中使用href=”javascript:void(0);”方法后在i6中点击失去使用;
  • (失去作用意思为:点击后已经到后台取到值但页面并没有更新) (continue reading…)

jQuery 获取对象

# 指示 id
. 指示 class
* 全选
, 多选
空格 后代
> 子
~ 兄弟
+ 下一个
: 子(多功能)
() 函数式的过滤与查找
(continue reading…)


select列表双向选择

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-

transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>select列表双向选择</title>
<script type=”text/javascript” src=”jquery-1.4.2.js”></script>
<style type=”text/css”>   (continue reading…)


Copyright © 1996-2010 Add Lives. All rights reserved.
iDream theme by Templates Next | Powered by WordPress