如有否像
$("#User_*")

解决方案 »

  1.   

    CSS 选择器 应该还没有强大到这种地步,需要自己写函数实现此功能。
      

  2.   

     if ($("#myid").length > 0) {          alert("控件存在");     }     else     {          alert("控件不存在!");     } 
      

  3.   

    (通配符: $("input[id^='code']");//id属性以code开始的所有input标签 $("input[id$='code']");//id属性以code结束的所有input标签 $("input[id*='code']");//id属性包含code的所有input标签
      

  4.   

    属性筛选(Attribute Filter):重要的筛选器,通常结合其他筛选器精确定位元素和元素集合,可以支持自定义属性 例如$("div[group='g1']"),匹配西面的所有带有group="g1"的div: 
    [attribute] 具有属性attribute
    [attribute=value] 属性值等于value
    [attribute!=value] 属性值不等于value
    [attribute^=value] 属性值以value开头(来源于正则表达式)比较有用,可以定义一组前缀可以统一管理。
    [attribute$=value] 属性值以value结尾(来源于正则表达式)
    [attribute*=value] 属性值包含value,无论开头结尾还是中间
    [attributeFilter1][attributeFilter2][attributeFilterN] 多重属性过滤,and关系型
      

  5.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                        "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
      <script src="http://code.jquery.com/jquery-latest.js"></script>
      
      <script>
      $(document).ready(function(){
        $("input[name^='news']").val("news here!");
      });
      </script>
      
    </head>
    <body>
      <input name="newsletter" />
      <input name="milkman" />
      <input name="newsboy" />
    </body>
    </html>
    http://docs.jquery.com/Selectors/attributeStartsWith#attributevalue还需要学习啊~
      

  6.   

    if 是同一种控件,比如input
    $("input[id^='User_']")
    else
    $("*[id^='User_']")
      

  7.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                        "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
      <script src="http://code.jquery.com/jquery-latest.js"></script>
      
      <script>
      $(document).ready(function(){
       $("#btn").click(function () {
        $("[id^='news']").each(function (i) {    
            if (this.tagName.toLowerCase()!= "input") {
              $(this).html("news here!");
            } else {
              $(this).val("news here!");
            }
          });//$("[id^='news']").each
        });//$("#btn").click    
      });//$(document).ready
      </script>
      
    </head>
    <body>
      <input id="newsletter" value='newsletter' />
      <input id="milkman" value='milkman' />
      <input id="newsboy" value='newsboy' />
      <span id='newspan'>sdfsdf</span>
      <input type='button' id='btn' value='change' />
    </body>
    </html>