2010-08-08 36 views
1

我有这个网站:我是怎样做到有jQuery来选择自定义HTML标签

Coral8 <del class="diffmod">SQL, to</del><ins class="diffmod">SQL,to</ins> improve 

我要抢<ins>标签。这些似乎是自定义HTML标记,所以我没有ID或类名。

jQuery选择器可以用来抓住它们的想法吗?

+0

用xpath来做这件事似乎更好,因为它必须来自xml文件。 – 2010-08-08 02:31:38

回答

6

只需使用element selector$('ins')。您自己尝试一下:

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <title>SO question 3432853</title> 
     <script src="http://code.jquery.com/jquery-latest.min.js"></script> 
     <script> 
      $(document).ready(function() { 
       alert($('ins').text()); // SQL,to 
      }); 
     </script> 
    </head> 
    <body> 
     <p>Coral8 <del class="diffmod">SQL, to</del><ins class="diffmod">SQL,to</ins> improve 
    </body> 
</html> 

It works。这些顺便说一下legitimately valid HTML tags