ari*_*iel 0 javascript css jquery
我有以下结构:
<div class="button">
<a href="/" target="_blank" class="test">Photos</a>
</div>
Run Code Online (Sandbox Code Playgroud)
使用JQuery如何选择.button并从html中删除target ="_ blank"?
我能够通过遵循JQuery文档来到这里,但我是新的并且迷失了.
$('.button').html("<a href="/" class="test">Photos</a>");
Run Code Online (Sandbox Code Playgroud)
$(".button a").removeAttr("target");
Run Code Online (Sandbox Code Playgroud)
虽然这很容易弄清楚它的作用,但removeAttr()方法将删除从选择器调用的所有/所有html属性.
这是文档:http://api.jquery.com/removeattr/