使用jQuery剥离HTML标签时出错



我使用以下代码从data字符串剥离HTML标签。

$($(data).text()).text();

导致控制台的以下错误。

jquery-1.11.1.min.js:2 Uncaught Error: Syntax error, unrecognized expression: API to manage person entities in the customer care system.Operation Detail - Create PersonCreates a new personURI: /customer/v1/PersonsHTTP  Method: POST
    at Function.fb.error (jquery-1.11.1.min.js:2)
    at fb.tokenize (jquery-1.11.1.min.js:2)
    at fb.select (jquery-1.11.1.min.js:2)
    at Function.fb [as find] (jquery-1.11.1.min.js:2)
    at m.fn.init.find (jquery-1.11.1.min.js:2)
    at new m.fn.init (jquery-1.11.1.min.js:2)
    at m (jquery-1.11.1.min.js:2)
    at eval (eval at render (pg-top-assets-table.js:17), <anonymous>:1:1)
    at render (pg-top-assets-table.js:17)
    at jquery.dataTables.min.js:18

字符串如下,

API to manage person entities in the customer care system.<p style="text-decoration: underline;"><h4><strong>Operation Detail - Create Person</strong></h4></p><p>Creates a new person</p><p><strong>URI: </strong>/customer/v1/Persons</p><p>HTTP  Method: POST</p>
$($(data).text()).text();

这是错误的,所以要像这样归注:

$("#"+$(data).text()).text();

最新更新