Deprecated
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
O método sub()
cria um elemento HTML <sub>
que faz com que a string seja exibida como subscript.
Sintáxe
str.sub()
Valor Retornado
Uma string contendo um elemento HTML <sub>
.
Descrição
O método sub()
embute uma string em uma tag <sub>
: "<sub>str</sub>"
.
Exemplos
Usando os métodos sub()
e sup()
Os exemplos seguintes usam o métodos sub() e sup()
para formatar uma string:
var superText = 'superscript'; var subText = 'subscript'; console.log('This is what a ' + superText.sup() + ' looks like.'); // This is what a <sup>superscript</sup> looks like console.log('This is what a ' + subText.sub() + ' looks like.'); // This is what a <sub>subscript</sub> looks like.
Especificação
Especificação | Status | Comentário |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'String.prototype.sub' in that specification. |
Padrão | Definição inicial. Implementado em JavaScript 1.0. Definido no (normativo) Anexo B for Additional ECMAScript Features for Web Browsers. |
ECMAScript Latest Draft (ECMA-262) The definition of 'String.prototype.sub' in that specification. |
Rascunho | Definido no (normativo) Anexo B for Additional ECMAScript Features for Web Browsers. |
Compatibilidade de Navegador
Estamos convertendo nossos dados de compatibilidade para o formato JSON.
Esta tabela de compatibilidade ainda usa o formato antigo,
pois ainda não convertemos os dados que ela contém.
Descubra como você pode ajudar!
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Suporte básico | (Yes) | 1.0 (1.7 or earlier) | (Yes) | (Yes) | (Yes) |
Característica | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Suporte básico | (Yes) | (Yes) | 1.0 (1.0) | (Yes) | (Yes) | (Yes) |