如何让jQuery选择自定义HTML标记

leo*_*ora 2 html jquery

我有这个HTML:

Coral8 <del class="diffmod">SQL, to</del><ins class="diffmod">SQL,to</ins> improve
Run Code Online (Sandbox Code Playgroud)

我想抓住<ins>标签.这些似乎是自定义HTML标记,所以我没有ID或类名.

有关哪个jQuery选择器可以用来抓住它们的想法?

Bal*_*usC 8

只需使用元素选择器 $('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>
Run Code Online (Sandbox Code Playgroud)

它有效.这些是合法有效的 HTML标签.