日期:2014-05-16  浏览次数:20315 次

这段jquery代码错在哪里??
<!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=utf-8" />
<title>无标题文档</title>
</head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function(){
$(":header").css("background-color","#cccccc");
$(":text").val("please input something...").css("color","#666666");
});
if($(":text:focus")){
  this.select();
}
</script>
<body>
<h1>title</h1>
<form action="">
<table>
  <tr>
  <td><input type="text" /></td>
  <td><input type="button" value="click"/></td>
  </tr>
  <tr>
  <td><input type="radio" />boy</td>
  <td></td>
  </tr>
</table>
</form>
</body>
</html>


显示对象不支持该属性的错误提示,14行

那我要实现选中,那一行要怎么改才好

------解决方案--------------------
JScript code
$(function(){
$(":header").css("background-color","#cccccc");
$(":text").val("please input something...").css("color","#666666");
$(":text").click( function() {
    $(this).select();
});
});

------解决方案--------------------
选择有问题
------解决方案--------------------
你要把代码放在$(function(){
//中间
})

------解决方案--------------------
应该是你的这个this.select(); 指向有问题!!!这个没有指向你的文本而是指向了文档
------解决方案--------------------
$("img[src][width]").attr("src","images/lunbo_title03.gif");这句有问题
第一:图片是不是没有找到?
第二:<td><img src="" width="" height="" /></td> width height加上属性值,否则图片显示不出来
------解决方案--------------------
7楼正解,再说了 this是js的方法啊 $(this)才是jq
------解决方案--------------------
你上面用的是$(":text:focus"),那么你下面同样用$(":text:focus")就行了,我看不出来那里能this.select()
------解决方案--------------------
this.select();要替换成 $(this).attr("checked","checked");

选中应该是 checked属性的更改; 
还有要区分下 this 和 $(this)的区别