简体   繁体   English

我正在寻找 HTML 属性的更多选项/信息:“contenteditable = 'true'”和 javascript:“focus()”function

[英]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.

相关问题 HTML 5使用javascript切换contenteditable属性 - HTML 5 toggling the contenteditable attribute with javascript HTML / JAVASCRIPT:在contentEditable = true中禁用HTML内容 - HTML / JAVASCRIPT : Disable HTML CONTENT in contentEditable=true 编码新手......我正在寻找一种功能,可以使用 Javascript 按 html 中的标签名称删除元素? - New to coding ...I am Looking for a function to delete elements by tag name in html with Javascript? javascript使用data-属性和值将焦点设置在contenteditable区域上 - javascript set focus on contenteditable area using data- attribute and value 将属性 false 设置为 true 时无法立即聚焦文本 contenteditable reactjs - Cannot focus text instantly contenteditable when set attribute false to true reactjs html contenteditable属性 - html contenteditable attribute 添加了contenteditable =“true”的DIV不会关注点击 - DIV with added contenteditable=“true” does not focus on click 为什么我不能在带有'contenteditable'属性的HTML按钮的文本中添加空格? - Why can I not add a space to the text of a HTML button with the 'contenteditable' attribute? 我正在寻找使用我在javascript中制作的公式的修复程序 - I am looking for a fix with a formula that I am making in javascript 在具有div contenteditable =“ true” javascript的编辑器中,在光标的clientX和ClientY位置插入HTML - Insert Html at clientX and ClientY position of cursor in editor having div contenteditable=“true” javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM