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.
El mètode sub()
crea un element HTML <sub>
que fa que una cadena es mostri com a subíndex.
Sintaxi
str.sub()
Descripció
El mètode sub()
incrusta una cadena a una etiqueta <sub>
: "<sub>str</sub>"
.
Exemples
Utilitzar els mètodes sub() i sup()
El codi següent utiltza els mètodes sub()
i sup()
per donar format a una cadena:
var superText="superíndex";
var subText="subíndex";
console.log("Així es com es veu un " + superText.sup());
// Així es com es veu un <sup>superíndex</sup>.
console.log("Així es com es veu un " + subText.sub());
// Així es com es veu un <sub>subíndex</sub>.
Especificacions
Especificació | Estat | Comentaris |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'String.prototype.sub' in that specification. |
Standard |
Definició inicial. Implementat en JavaScript 1.0. Definit en l'Annex B (normative) per a Característiques Addicicionals d'ECMAScript per Navegadors Web. |
Compatibilitat amb navegadors
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Suport bàsic | (Yes) | 1.0 (1.7 or earlier) | (Yes) | (Yes) | (Yes) |
Característica | Android | Chrome per Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Suport bàsic | (Yes) | (Yes) | 1.0 (1.0) | (Yes) | (Yes) | (Yes) |