开发者

Get Text from "href" with dojo?

开发者 https://www.devze.com 2022-12-21 09:23 出处:网络
i \'ve the following html: <table id=\"mytable\"> <thead> </thead> <tbody> <tr>

i 've the following html:

<table id="mytable">
    <thead>
    </thead>
    <tbody>
        <tr>
            <td><a href="#" onclick="doSometThingCrazy(); return false;">test</a></td>
        </tr>
    </tbody>
</table>

Now i want to get all links inside this tabl开发者_JAVA技巧e with dojo. So far so good:

  dojo.query("#mytable a").forEach(
          function(item){
               dojo.connect(item, 'onmouseover', function(){
                   console.log(item);
                   console.log('x');
               });
          }
     );

Now i want to get the text for the href (test) and look for it in an other table. Is there anyway to access this value ?


If you just want text and no HTML markup to worry about, use:

dojo.dom.textContent(item)


You can check its innerHTML, I do not know any css selector for its innerHTML.

 dojo.query("#mytable a").forEach(
      function(item){
           if(dojo.attr(item, "innerHTML") == "TEXT")
               dojo.connect(item, 'onmouseover', function(){
                   console.log(item);
                   console.log('x');
               });
      }
 );
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号