使用YUI删除超链接

时间:2014-05-10 19:26:14

标签: yui

我的html中有以下内容:

Logged in as <a title="View Profile" href="http://xxx/user/profile.php?">Peter Pan</a>

我想删除上面的超链接,这样仍然显示&#34;登录为Peter Pan&#34;但是没有彼得潘连接到任何地方。

由于

2 个答案:

答案 0 :(得分:0)

假设YUI 3:node.set('innerHTML', node.get('innerHTML').replace(/<[^>]+>/g, ''));

请注意,这并不像普通正则表达式那样需要YUI:)

答案 1 :(得分:0)

使用Node.removeAttribute方法移除锚点href

查看YUI API中的文档:

http://yuilibrary.com/yui/docs/api/classes/Node.html#method_removeAttribute

Y.one('some selector for the anchor here').removeAttribute('href');