[英]I am looking for more options / information for the HTML attribute: “contenteditable = 'true'” and the javascript: “focus()” function
I would like to learn more about the "HTML contenteditable =' true '" attribute and the javascript focus () function.我想详细了解“HTML contenteditable =' true '”属性和 javascript 焦点 () function。 For example, I would like to know how I can influence the position of the focused line or how to edit the background of a focused line.
例如,我想知道如何影响焦点线的 position 或如何编辑焦点线的背景。 I have already googled some things but I can't find the right information.
我已经用谷歌搜索了一些东西,但我找不到正确的信息。
Does anyone have a good tip?有没有人有好的提示?
You can check which element is on focus by writing in the Google Chrome console:您可以通过在 Google Chrome 控制台中写入来检查哪个元素是焦点:
document.activeElement
The contenteditable attribute specifies whether the content of an element is editable or not. contenteditable 属性指定元素的内容是否可编辑。
If you want to trigger the focus on a contenteditable element you can do it by:如果您想触发对 contenteditable 元素的关注,您可以通过以下方式实现:
$(".contenteditableClassName").focus();
Any other background change on this element is done by CSS for example you can use此元素的任何其他背景更改由 CSS 完成,例如您可以使用
.no-touchevents &:hover, &:focus, &:active {
border-color: white;
color: blue;
You can apply different changes on the element on focus this way.您可以通过这种方式对焦点元素应用不同的更改。
Also you can remove the focus border on click by using:您还可以使用以下方法删除单击时的焦点边框:
.pointer-focus &:focus {
outline: none;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.