0

How to initilize dynamic number with in css selector?

   Ex-pageUrl.QuerySelector(.attachment-type-table .qa-type-id-label-for-25)

The above line given only one Result Photograph.

I need to get all names with in span tag

( qa-type-id-label-for-26,qa-type-id-label-for-25, qa-type-id-label-for-27 etc)
StanislavL
  • 56,971
  • 9
  • 68
  • 98
reshma
  • 3
  • 3
  • Transfer cover Photograph – reshma Apr 29 '15 at 06:26
  • Are you using jQuery ? Or [querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) ? **Note:** `querySelector` will select only first matched element. If you want to access every matched element, use [querySelectorAll](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll) – Vigneswaran Marimuthu Apr 29 '15 at 06:29
  • You could check this post http://stackoverflow.com/questions/190253/jquery-selector-regular-expressions – HJK Apr 29 '15 at 06:32
  • im using queryselector. how to initilize with queryselectorAll?Is this correct? Ex:.pageUrl.QuerySelectorAll(.attachment-type-table .qa-type-id-label-for-25).i can get only 25 object only .i need 26 and 27 too.... – reshma Apr 29 '15 at 06:34
  • @reshma Use like `document.querySelectorAll('#attachmentTypeTable span')`. This will return you list of matched elements – Vigneswaran Marimuthu Apr 29 '15 at 06:36
  • @VigneswaranMarimuthu i have tried with your code.im getting only one value – reshma Apr 29 '15 at 06:40
  • @reshma I tried using the markup you have commented but i don't see it is valid. Can you provide a jsfddle link ? – Vigneswaran Marimuthu Apr 29 '15 at 06:46

2 Answers2

0

Use native function yourSpan.attr('class'), and then you can use .Split(" ") for get individual of class.

ketan
  • 19,129
  • 42
  • 60
  • 98
lails
  • 105
  • 11
0

Is this what you are trying to do? I have implemented querySelectAll() matching partially to a class name.

<table id="attachmentTypeTable" class="appconfig-data-table attachment-type-table">
    <tbody>
    <tr>
    <tr id="28RemoveAType">
    <tr id="27RemoveAType">
    <tr id="26RemoveAType">
        <td><span class="qa-type-id-label-for-26">Transfer cover</span></td>
        <td>
    </tr>
    <tr id="25RemoveAType">
        <td><span class="qa-type-id-label-for-25">Photograph</span></td>
        <td>
    </tr>
    </tbody>
    </table>
<script type="text/javascript">
    var x = document.querySelectorAll('[class^="qa-type-id-label-for-"]');
    for(var i=0;i< x.length;i++){
        document.write('result'+i+':'+x[i].innerHTML+'<br/>');
    }

</script>
ketan
  • 19,129
  • 42
  • 60
  • 98
YongUn Choi
  • 366
  • 2
  • 4
  • im unable to get the values .firefox gets crashed when execute this line. var filetype= aqObject.GetPropertyValue(Page.QuerySelectorAll('[class^="qa-type-id-label-for-"]'), "contentText") – reshma Apr 29 '15 at 11:46