Próbuję napisać kod do stronicowania. Jedną z funkcji jest wyłączenie bieżącego łącza tak, aby wyglądało jak tekst i było niemożliwe do skasowania. W stronę html może to być osiągnięte przez pominięcie atrybutu href jak:Usuwanie atrybutu href
<a>Link</a>
nie mogłem zrobić w JavaScript,
AvdonPagination.prototype.manageLinks = function(link){
if(link){
this.current.href = '#';
this.current = link;
}else{
this.current = this.links[0];
}
this.current.href = null;
}
ponieważ
this.current.href = null;
produkuje
<a href="null">Link</a>
Próbowałem także this.current.href=""
i this.current.disabled=true
, ale żadna z nich nie działa. Jak mogę osiągnąć <a>Link</a>
?
widziałeś http://stackoverflow.com/questions/2533406/how-to-disable-a-html-tag –
Czy próbowałeś removeAttribute? https://developer.mozilla.org/en-US/docs/Web/API/element.removeAttribute – zdyn
Aby usunąć atrybut z elementu użyj removeAttribute – Musa