解决方案 »
- Ext的同步、异步问题
- 请问,如何用javascript设置WMV的宽和高???
- 关于嵌入式Linux+web网页问题
- 一段代码不知哪错
- 如何呼叫iframe中javascript的function?
- 怎么右键点击 .net web form的datagrid弹出菜单?解决后再放100分,顶着有分
- 如何用js判断商传图片的高度和宽度??特别急!!
- 有很多相同的Input项目,当输入出错时,想高效率得对他们的背景色都设为红色?
- 在一个页中onmousedown能被赋予两个不同的函数吗?????
- e.stopPropagation() 为何不起作用,求解?
- 请高手将下列C#转成JS代码
- Js语句执行顺序问题
改成 var $c=$("#conlen");
或着 var $c=$(".cc");
试下。。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#conl").change(function(){
var $c=$(".conlen");
/* if($(this).val()==""){
$("conlen").attr("value","maxlength@15");
}
if($(this).val()!=""){
$("conlen").attr("value",("maxlength@"+$(this.val())));
}*/
if($c.val()=="maxlength@15"){
$c.val("maxlength@15");
$c.removeAttr("checked",'false');//去除选中
}else{
//$c.attr("value","maxlength@"+$(("#conl").val()));
$c.val("maxlength@"+$(this.val()));
$c.attr("checked",true);//选中
}
alert($c.val());
});
$("[name=button]").click(function(){
alert($("#conlen").val())
});
});
</script>
</head><body><form action="" method="post"><input name="button" type="button" value="button" /><input type="checkbox" id="conlen" name="con" class="cc" value="maxlength@15"/>maxlength@15
要控制的长度:<input type="text" name="co11n" value="" id="conl" class="ckinput"/>
</form>
</body>
</html>不懂你要什么
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(function(){
$("#conl").change(function(){
if($(this).val()!=""){
var num=$(this).val();
$("#conlen").val("maxlength@"+num);
$("#la").html("maxlength@"+num);
$("#conlen").attr("checked","checked");
}else{
$("#conlen").attr("checked","");
$("#conlen").val("maxlength@15");
$("#la").html("maxlength@15");
}
}) $("input[name=button]").click(function(){
alert($("#conlen").val())
});})
</script>
</head><body><form action="" method="post"><input name="button" type="button" value="button" /><input type="checkbox" id="conlen" name="con" class="cc" value="maxlength@15"/><label id="la">maxlength@15</label>
要控制的长度:<input type="text" name="co11n" value="" id="conl" class="ckinput"/>
</form>
</body>
</html>