我如何 select jQuery 中的自定义元素?

How do I select a custom element in jQuery?

我有一个自定义标签,如下所示,但似乎无法 select 使用 select 或 $("ix:nonNumeric")。然而,$("[contextRef]") 工作正常。正确的 select 或

是什么?
<ix:nonNumeric contextRef="PERIOD0" name="se-gen-base:VasentligaHandelserRakenskapsaret" >000</ix:nonNumeric>

您需要在自定义标签中转义冒号:

$("ix\:nonNumeric").text()

示例:

console.log( $("ix\:nonNumeric").text() )
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ix:nonNumeric contextRef="PERIOD0" name="se-gen-base:VasentligaHandelserRakenskapsaret" >000</ix:nonNumeric>

正如 selectors 的文档所述:

To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \