<!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行那我要实现选中,那一行要怎么改才好

解决方案 »

  1.   

    我修改成这样,这样的话,错在哪?
    <!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();
    }
    $("input[type][value]").val("点击");
    $("img[src][width]").attr("src","images/lunbo_title03.gif");
    </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><img src="" width="" height="" /></td>
        </tr>
    </table>
    </form>
    </body>
    </html>
      

  2.   

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

  3.   

    哦,不好意思可以选中了我试了一下。不过请问其中的$("input[type][value]").val("点击");
    $("img[src][width]").attr("src","images/lunbo_title03.gif");为什么没有效果?就是实现让按钮加上文字和图片加上链接图,两个中括号的语法也是参考jquery说明书的,不会错的,那错在哪?
      

  4.   

    你要把代码放在$(function(){
       //中间
    })
      

  5.   

    应该是你的这个this.select(); 指向有问题!!!这个没有指向你的文本而是指向了文档
      

  6.   

    $("img[src][width]").attr("src","images/lunbo_title03.gif");这句有问题
    第一:图片是不是没有找到?
    第二:<td><img src="" width="" height="" /></td> width height加上属性值,否则图片显示不出来
      

  7.   

    7楼正解,再说了 this是js的方法啊 $(this)才是jq
      

  8.   

    你上面用的是$(":text:focus"),那么你下面同样用$(":text:focus")就行了,我看不出来那里能this.select()
      

  9.   

    this.select();要替换成 $(this).attr("checked","checked");选中应该是 checked属性的更改; 
    还有要区分下 this 和 $(this)的区别
      

  10.   

    搞懂了原来是要放在function里面