Change Survey HTML with JavaScript

Edit in →

SurveyJS Form Library offers multiple customization options for survey elements (panels and questions):

  • Configure templates for answer options in single- and multi-select questions (View Demo)
  • Implement custom question renderers based on built-in question types (View Demo)
  • Create custom question types (View Demo)

If none of these options meets your requirements, you can handle events to modify HTML markup of individual survey elements. The SurveyModel class raises the following events for this purpose:

Each of these events accepts the options.htmlElement parameter, which contains an HTMLElement object. You can use its properties and methods to change HTML markup in your JavaScript code. For example, this demo shows how to add tooltips to question titles. Tooltip texts are specified in a question's title property and are separated from the title text by a special character combination ("||"). The onAfterRenderQuestion event handler splits the title property value and assigns title text to HTMLElement's innerText property and the tooltip text to HTMLElement's title property. Hover the mouse pointer over a question title to see its tooltip.

Your cookie settings

We use cookies on our site to make your browsing experience more convenient and personal. In some cases, they are essential to making the site work properly. By clicking "Accept All", you consent to the use of all cookies in accordance with our Terms of Use & Privacy Statement. However, you may visit "Cookie settings" to provide a controlled consent.

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.