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

时间:2010-08-08 02:30:19

标签: jquery html

我有这个HTML:

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

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

有关jQuery选择器可用于抓取它们的任何想法吗?

1 个答案:

答案 0 :(得分:8)

只需使用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

相关问题