DOM state

This demo covers small DOM helpers that read and change element state: tp.Enabled(), tp.ReadOnly(), and tp.TabIndex(). These helpers are useful when code works directly with plain DOM elements instead of Tripous components or controls.

tp.Enabled() uses the native disabled property when the element supports it. For a plain HTMLElement such as a div, it toggles the tp-Disabled CSS class. tp.ReadOnly() uses the native readOnly property for text inputs and textareas. For checkboxes and radio buttons it uses disabled, because those elements do not have a useful read-only state. tp.TabIndex() reads or writes the browser tabIndex value.

Sample elements

The buttons operate on these plain DOM elements and write the current state below.

button
plain div
Plain HTMLElement

Enabled

The button and input use their native disabled property. The plain div receives or loses the tp-Disabled CSS class.

Read-only

Text input read-only state uses readOnly. Checkbox read-only state uses disabled, matching the old Tripous behavior.

TabIndex and focus

The plain div starts with tabindex="-1". The test sets tabIndex to 0, focuses the div, and checks tp.IsFocused() and tp.HasFocused().