2010-08-08 18 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