<input id="abc...">这里的abc后面还跟着一些字母,但是不确定是哪些字母想要获取这个id属性的值,请问怎么做?
谢谢

解决方案 »

  1.   

    貌似是这样$("input[id^='abc']").attr("id")多个input要each迭代
      

  2.   

    不好意思,我说错了
    <input abc...="属性值">这里的abc后面还跟着一些字母,但是不确定是哪些字母
    我要的是abc...这个不确定的属性的属性名(比如说abcmmm)
      

  3.   

    var abcmmm = abcmmmdocument.getElementsByTagName('input')[0].getAttribute('abcmmm')
      

  4.   

    问题是不是有问题啊。html文档模型的属性名可以自己写的吗?
      

  5.   

    用解XML的方式,然后,采用正则(?)是可以做到的。
      

  6.   


    键一般都是预知的
    变化的是值比如你这样写<input id='ip'  key='abcxxx:属性值' />
    这样通过key不就可以拿到整个的了
      

  7.   

    $('#....').attr('name') 获得名字为name的属性
    $('#....').attr('name', value) 将属性name的值设置为value
      

  8.   

    一般常用的标签的属性呀,都是预知的呀,变化的都是属性的值咯
    除非是你自己定义的标签,自己写的属性才不知道,(自己都不知道,怎么用,呵呵,)
    要不然的话,属性都就那些,还有什么不知道后面什么字母的呢,wan
      

  9.   

    以下是JQAPI文档中的一个例子:HTML代码:
    <img src="test.jpg"/> JQ代码:
    $("img").attr("src"); 若是根据ID来取,则JQ代码为
    $("#ID名称").attr("src"); 结果:
    test.jpg 
      

  10.   

    不是,元素的属性是可以自己加的<input jquery123="555">这个是没有问题的。
    现在是不知道jquery...具体是什么,可能是jquery123,可能是jquery456,反正是不确定
    折中的办法是获取上一个元素td的innerHTML值,然后用正则来获取jquery...
    可能#5楼说的就是这个意思?<input type="text" name="aaa" id="bbb" value="点击" jquery2="mmm" />
    <script>
    alert(document.getElementById("bbb").getAttribute("jquery2"));
    </script>
      

  11.   

    按1楼的来,可以得到这个input对象,可以考虑呀,
    但是要重新获得属性名,可以再想办法wan
      

  12.   

    所有属性名称一条一条对比,发现竟然有100多条。<input type="text" name="aaa" id="bbb" value="点击" jquery2="mmm" />
    <br>
    <script type="text/javascript">
    var obj = document.getElementById("bbb");
    var str = "";
    var reg = new RegExp("jquery","ig");
    for(p in obj.attributes) {
      //str += p + "<br>";
      if(reg.test(p)) {
        alert(p);
        break;
      }
    }
    //document.write(str);
    </script>
      

  13.   

    <!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>测试attributes</title><link href="" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <table border="1" cellspacing="10" style="border:solid 1px">
    <tr>
    <td width="100" rowspan="" >&nbsp;
    </td>
    <td width="100">&nbsp;

    </td>
    <td width="100"><input type="text" name="aaa" id="bbb" value="点击" jquery2="mmm" />
    </td>
    </tr>
    <tr id="d">
    <td width="100" id="col"><input type="text" name="aaa" id="bbb" value="点击" jquery2434="mmm" />

    </td>
    <td width="100">&nbsp;

    </td>
    <td width="100">&nbsp;

    </td>
    </tr>
    <tr>
    <td width="100">&nbsp;

    </td>
    <td width="100">&nbsp;

    </td>
    <td width="100">  <audio src="someaudio.wav">
      您的浏览器不支持 audio 标签。
      </audio> 

    </td>
    </tr>
    </table>
    </body>
    </html> 
    <script>var obj = document.getElementById("bbb");
    var str = "";
    for(p in obj.attributes) {
      alert(p+"开始")
      for (m in obj.attributes[p])
      {
      alert(m+":"+obj.attributes[p][m])
      }
    }
    alert(obj.attributes["length"])
    /*//下面是运行结果
    0开始
    nodeName:name
    nodeValue:aaa
    ownerDocument:[object HTMLDocument]
    ownerElement:[object HTMLInputElement]
    firstChild:null
    lastChild:null
    childNodes:null
    nextSibling:null
    parentNode:null
    expando:false
    value:aaa
    specified:true
    nodeType:2
    name:name
    previousSibling:null
    attributes:null

    1开始
    nodeName:id
    nodeValue:bbb
    ownerDocument:[object HTMLDocument]
    ownerElement:[object HTMLInputElement]
    firstChild:null
    lastChild:null
    childNodes:null
    nextSibling:null
    parentNode:null
    expando:false
    value:bbb
    specified:true
    nodeType:2
    name:id
    previousSibling:null
    attributes:null

    2开始
    nodeName:type
    nodeValue:text
    ownerDocument:[object HTMLDocument]
    ownerElement:[object HTMLInputElement]
    firstChild:null
    lastChild:null
    childNodes:null
    nextSibling:null
    parentNode:null
    expando:false
    value:text
    specified:true
    nodeType:2
    name:type
    previousSibling:null
    attributes:null

    3开始
    nodeName:jquery2
    nodeValue:mmm
    ownerDocument:[object HTMLDocument]
    ownerElement:[object HTMLInputElement]
    firstChild:null
    lastChild:null
    childNodes:null
    nextSibling:null
    parentNode:null
    expando:true//这个可能是表明是扩展属性
    value:mmm
    specified:true
    nodeType:2
    name:jquery2
    previousSibling:null
    attributes:null

    4开始
    nodeName:value
    nodeValue:点击
    ownerDocument:[object HTMLDocument]
    ownerElement:[object HTMLInputElement]
    firstChild:null
    lastChild:null
    childNodes:null
    nextSibling:null
    parentNode:null
    expando:false
    value:点击
    specified:true
    nodeType:2
    name:value
    previousSibling:null
    attributes:null

    length开始
    5
    */
    </script>