1

单击它后,我正在尝试删除超链接。(分页)

我希望删除超链接但仍显示文本。

<a href='#'>1</a>
<a href='#'>2</a>
<a href='#'>3</a>   //remove the hyperlink but keep number 3.
<a href='#'>4</a>
<a href='#'>5</a>

感谢您的帮助。

4

3 回答 3

3
$('a').click(function(){
    $(this).removeAttr("href");
});
于 2012-08-09T21:33:47.860 回答
3

jsBin 演示

$('a').click(function(e){
  e.preventDefault();          // if you need it
  $(this).contents().unwrap();
});

http://api.jquery.com/contents/
http://api.jquery.com/unwrap/

于 2012-08-09T21:36:20.260 回答
2

怎么样:

$('a').click(function(){
    $(this).replaceWith($(this).html());
});

jsfiddle

于 2012-08-09T21:30:28.343 回答