//textarea length属性为 'mylength' 键盘抬起验证事件 span cation属性 'num' 赋值
$("textarea[length='lang']").bind("mouseover blur keyup",
function(){
$(this).siblings("span[name='inputnum']").html($(this).val().length);
var max = parseInt($(this).attr("maxlength"), 10);
if($(this).val().length>max){
alert("输入的字符数超出范围,最多可以输入"+max+"个字!");
$(this).val($(this).val().substr(0, max)); //截断textarea的文本重新赋值
$(this).parents('div').find("span[cation='num']").html($(this).val().length);
}
}
)
- jQuery("#id").click(func1).mouseover(func2)//方法连写,func为方法的名字
- jQuery("#id").click(function(){//你的具体方法实现}),mouser(function(){//你的具体方法实现});
- jQuery("#id").bind("click mouseover",func)//两个事件中间有空格 ,func为方法的名字
- jQuery("#id").bind("load scroll",function(){//你的具体方法实现});