GetElement

function GetElement(nPos: number = null): ParagraphContent

Description

Returns an element of the current inline text content control using the position specified.

Parameters

nPosnumberdefault: null

The position where the element which content we want to get must be located.

Returns

ParagraphContent

Try It

var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var oInlineLvlSdt = Api.CreateInlineLvlSdt();
oParagraph.AddInlineLvlSdt(oInlineLvlSdt);
for (let nPos = 0; nPos < 10; ++nPos) {
   var curRun = Api.CreateRun();
   curRun.AddText("This is text run " + (nPos + 1) + ". ");
   oInlineLvlSdt.AddElement(curRun);
}
var changeRun = oInlineLvlSdt.GetElement(4);
changeRun.SetBold(true);
oParagraph.AddLineBreak();
oParagraph.AddLineBreak();
oParagraph.AddLineBreak();
oParagraph.AddText("We added 10 text runs to the above inline text content control. Then we changed the fifth run, so it is different from the others.");

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).