HTMLLabelElement

HTMLLabelElement

概述

HTMLLabelElement 是 Aspose.Html FOSS 中用于 Python 的类。继承自:HTMLElement.

HTML <label> 元素。

此类提供了 78 个用于在 Python 程序中处理 HTMLLabelElement 对象的方法。可用的方法包括:__init__, add_event_listener, after, append, append_child, attach_shadow, before, blur, check_visibility, click, clone_node, closest,以及另外 66 个方法。所有公共成员在安装 Aspose.Html FOSS for Python 包后,可供任何 Python 应用程序访问。属性:access_key, access_key_label, assigned_slot, attributes, autocapitalize, autofocus,以及另外 67 项。

属性

名称类型访问描述
html_forstr读写该 for 属性值,以 html_for 形式公开。
control`“ElementNone”`读取
form`“HTMLElementNone”`读取
hiddenbool读写元素是否隐藏(反映 hidden 布尔属性)。
titlestr读写此元素的工具提示标题(反映 title 属性)。
langstr读写元素内容的语言(反映 lang 属性)。
tab_indexint读写此元素的制表顺序索引(反映 tabindex 属性)。
access_keystr读写此元素的键盘快捷键(反映 accesskey
    attribute). |

| content_editable | str | 读/写 | 反映 contenteditable 属性 (WHATWG HTML §6.6)。 | | is_content_editable | bool | 只读 | 此元素当前是否可编辑 (WHATWG HTML §6.6)。 | | dir | str | 读/写 | 元素的文本方向性 (反映 dir 属性)。 | | draggable | bool | 读/写 | 元素是否可拖拽 (反映 draggable 属性)。 | | spell_check | bool | 读/写 | 拼写检查是否已启用 (反映 spellcheck 属性)。 | | spellcheck | bool | 读/写 | 拼写检查是否已启用 (反映 spellcheck 属性)。 | | autocapitalize | str | 读/写 | 自动大写提示 (反映 autocapitalize 属性)。 | | nonce | str | 读/写 | CSP 的加密 nonce (反映 nonce 属性)。 | | autofocus | bool | 读/写 | 页面加载时此元素是否应获得焦点。 | | access_key_label | str | 只读 | 系统分配的访问键标签 (无头存根:始终为 '')。 | | input_mode | str | 读/写 | 虚拟键盘输入模式提示 (反映 inputmode 属性)。 | | enter_key_hint | str | 读/写 | Enter 键操作标签提示 (反映 enterkeyhint 属性)。 | | translate | bool | 读/写 | 此元素是否启用了翻译 (WHATWG HTML §6.1.2)。 | | inner_text | str | 读/写 | 渲染的文本内容 — 空白字符已折叠 text_content。 | | outer_text | str | 读/写 | 同 inner_text (getter 根据 HTML Standard §3.2.7 镜像 inner_text)。 | | popover | | Read/Write | Reflects thepopovercontent attribute (WHATWG HTML §6.12). | | node_name|str| Read | The qualified tag name (uppercase for HTML elements). | |tag_name|str| Read | The qualified tag name in uppercase (HTML elements). | |local_name|str| Read | The local part of the qualified name (lowercase). | |namespace_uri|str | None | Read | The namespace URI, orNonefor no namespace. | | style_sheets|“StyleSheetList”| Read | Live stylesheet list applicable to this element's document. | |prefix|str | None | Read | The namespace prefix, orNone. | | id|str| Read | The value of theidattribute, or’’if not present. | | class_name|str | Read | The value of theclassattribute, or’’. | | class_list|“DOMTokenList”| Read | Live mutable set of CSS class tokens backed by theclassattribute. | | dataset|“DOMStringMap” | Read | Live dict-like view of the element'sdata-*custom attributes. | | attributes|NamedNodeMap| Read | The ordered map of Attr objects for this element. | |children|HTMLCollection| Read | A live HTMLCollection of Element-type children only. | |first_element_child|Element | None | Read | The first Element child, orNone. | | last_element_child|Element | None| Read | The last Element child, orNone. | | next_element_sibling|Element | None| Read | The next sibling that is an Element, orNone. | | previous_element_sibling|Element | None| Read | The previous sibling that is an Element, orNone. | | child_element_count|int| Read | The number of Element children. | |inner_html|str| Read/Write | The serialised HTML content of all children (innerHTML). | |outer_html|str| Read/Write | The serialised HTML of this element and all its descendants (outerHTML). | |text_content|str | None| Read/Write | The concatenation of all descendant Text node data (DFS order). | |style|“CSSStyleDeclaration”| Read | The inline style of this element as a live CSSStyleDeclaration. | |scroll_width|int| Read | Content scroll width in CSS pixels (stub: 0). | |scroll_height|int| Read | Content scroll height in CSS pixels (stub: 0). | |client_width|int| Read | Inner width including padding, excluding border (stub: 0). | |client_height|int| Read | Inner height including padding, excluding border (stub: 0). | |scroll_top|int| Read/Write | Vertical scroll offset in CSS pixels (stub: 0). | |scroll_left|int| Read/Write | Horizontal scroll offset in CSS pixels (stub: 0). | |offset_width|int| Read | Layout border-box width in CSS pixels (stub: 0). | |offset_height|int| Read | Layout border-box height in CSS pixels (stub: 0). | |offset_top|int| Read | Top offset fromoffsetParentin CSS pixels (stub: 0). | | offset_left|int | Read | Left offset fromoffsetParentin CSS pixels (stub: 0). | | offset_parent|None | Read | The offset parent element; alwaysNonein headless mode. | | client_top|int | Read | Width of the top CSS border in pixels; always0in headless mode. | | client_left|int | Read | Width of the left CSS border in pixels; always0in headless mode. | | part|“DOMTokenList” | Read | Live DOMTokenList reflecting the elementpartattribute. | | shadow_root | | 只读 | 在无头模式下始终 None。 | | slot | str | 读/写 | 反映 slot 内容属性 (DOM §4.2.3)。 | | assigned_slot | | Read | AlwaysNonein headless mode. | | node_type|int | Read | Integer node type constant fromNodeType. | | node_value|str | None| Read/Write | Character data for CharacterData nodes;Noneotherwise. | | parent_node|Node | None | Read | The parent node, orNoneif this node has no parent. | | parent_element|Element | None | Read | The parent node if it is an Element;Noneotherwise. | | is_connected|bool| Read | Whether this node is part of a document's node tree (WHATWG DOM §4.4). | |owner_document|Document | None | Read | The Document this node belongs to, orNonefor Document itself. | | child_nodes|NodeList| Read | A live NodeList of all child nodes. | |first_child|Node | None | Read | The first child node, orNone. | | last_child|Node | None| Read | The last child node, orNone. | | previous_sibling|Node | None| Read | The preceding sibling node, orNone. | | next_sibling|Node | None| Read | The following sibling node, orNone``. |

方法

签名描述
click()在此元素上分派一个合成的 click 事件。
`focus(options: “dictNone”)`
blur()在此元素上分派一个非冒泡的 'blur' 事件。
show_popover()将此元素显示为 popover(在无头模式下为无操作)。
hide_popover()隐藏此元素的弹出框(在无头模式下为无操作)。
`toggle_popover(force: “boolNone”)→bool`
`init(local_name: str, namespace_uri: strNone, prefix: str
get_computed_style() → "ComputedStyleDeclaration"返回此元素的 phase-2 cascade-resolved 声明。
insert_adjacent_html(position: str, html: str)在此元素相对位置插入已解析的 HTML 标记。
insert_adjacent_text(position: str, text: str)在此元素相对位置插入文本节点。
`insert_adjacent_element(position: str, element: “ElementNone”)→“Element
get_attribute(name: str) → `strNone`
set_attribute(name: str, value: str)设置属性 name to value,如果不存在则创建。
remove_attribute(name: str)删除属性 name.
has_attribute(name: str) → boolReturn True 如果属性 name 存在于此元素。
get_attribute_node(name: str) → `“AttrNone”`
set_attribute_node(attr: "Attr") → `“AttrNone”`
remove_attribute_node(attr: "Attr") → "Attr"Remove attr 从此元素的属性集合中获取并返回它。
`get_attribute_node_ns(namespace_uri: strNone, local_name: str)→“Attr
set_attribute_node_ns(attr: "Attr") → `“AttrNone”`
`remove_attribute_node_ns(namespace_uri: strNone, local_name: str)→“Attr”`
`get_attribute_ns(namespace_uri: strNone, local_name: str)→str
`set_attribute_ns(namespace_uri: strNone, qualified_name: str, value: str)`
`has_attribute_ns(namespace_uri: strNone, local_name: str)→bool`
`remove_attribute_ns(namespace_uri: strNone, local_name: str)`
`toggle_attribute(name: str, force: boolNone)→bool`
get_attribute_names() → list[str]返回按集合顺序的所有属性的限定名称。
has_attributes() → bool当此元素具有一个或多个属性时,返回 True。
`scroll_into_view(arg: booldict
`scroll(x_or_options: floatdict
scroll_into_view_if_needed(center_if_needed: bool)如果此元素尚未可见,则将其滚动至视图中(在无头模式下为无操作)。
set_pointer_capture(pointer_id: int)将此元素指定为给定指针的捕获目标(无操作)。
release_pointer_capture(pointer_id: int)释放给定指针 ID 的指针捕获(无操作)。
has_pointer_capture(pointer_id: int) → bool返回此元素是否对给定 ID 具有指针捕获。
request_pointer_lock()请求将指针锁定到此元素(无操作)。
`request_fullscreen(options: “dictNone”)`
`check_visibility(options: “dictNone”)→bool`
query_selector(selector: str) → `ElementNone`
query_selector_all(selector: str) → NodeList返回所有匹配元素的静态 NodeList selector.
matches(selector: str) → boolReturn True 如果此元素匹配 CSS selector.
webkit_matches_selector(selector: str) → bool浏览器兼容别名,用于 :meth:matches。
closest(selector: str) → `“ElementNone”`
get_elements_by_tag_name(qualified_name: str) → HTMLCollection返回所有标签名匹配的子元素 qualified_name.
get_elements_by_class_name(class_names: str) → HTMLCollection返回所有包含所有给定类标记的后代元素。
filter_fn(el: "Element") → bool在此 HTMLLabelElement 实例上调用 filter_fn(el)。
remove()从其父节点中移除此元素。
before()Insert nodes 在其父节点中紧接此元素之前。
after()Insert nodes 在其父元素中紧跟此元素之后。
replace_with()将此元素替换为 nodes 在其父元素中。
prepend()Insert nodes 在此元素的第一个子元素之前。
append()Append nodes 作为此元素的最后子元素。
replace_children()删除所有子节点,然后追加 nodes 作为新子节点。
get_bounding_client_rect() → "DOMRect"返回边界客户端矩形(全零存根)。
get_client_rects() → "DOMRectList"返回客户端矩形列表(在服务器端上下文中为空)。
get_animations() → list[object]返回此元素的活动动画(无头存根:始终为 [])。
`attach_shadow(init: “dictNone”)`
get_root_node(composed: bool) → "Node"返回该节点树的根节点。
has_child_nodes() → bool返回此节点是否至少拥有一个直接子节点。
`lookup_namespace_uri(prefix: strNone)→str
`lookup_prefix(namespace_uri: strNone)→str
`is_default_namespace(namespace_uri: strNone)→bool`
`is_supported(feature: str, version: strNone)→bool`
`get_feature(feature: str, version: strNone)→object
`set_user_data(key: str, data: objectNone, handler: object
get_user_data(key: str) → `objectNone`
append_child(node: Node) → NodeAppend node 作为此节点的最后一个子节点。
`insert_before(node: Node, reference: NodeNone)→Node`
remove_child(node: Node) → NodeRemove node 从子列表中取出并返回它。
replace_child(new_child: Node, old_child: Node) → NodeReplace old_child with new_child.
clone_node(deep: bool) → Node返回此节点的副本。
normalize()将此节点及其整个子树转换为标准化形式。
`contains(other: NodeNone)→bool`
compare_document_position(other: "Node") → int返回描述位置的位掩码 other 相对于此节点。
`is_equal_node(other: NodeNone)→bool`
`is_same_node(other_node: NodeNone)→bool`
add_event_listener(type: str, listener: Callable, capture: bool, once: bool)Register listener 用于以下事件的 type.
remove_event_listener(type: str, listener: Callable, capture: bool)注销先前已注册的监听器。
dispatch_event(event: "Event") → boolDispatch event 通过祖先树。

另请参阅

 中文