gpt4 book ai didi

javascript - jQuery contentEditable 不起作用 - Internet Explorer 8 - 编辑表项目

转载 作者:行者123 更新时间:2023-11-28 20:29:55 25 4
gpt4 key购买 nike

我需要让此代码在 Internet Explorer 8 中运行:

http://jsfiddle.net/tYtQV/5/

$("tbody tr td").bind("click", onClick);

function onClick(e) {
if(e.currentTarget.contentEditable != null)
{
$(e.currentTarget).attr("contentEditable",true);
}
else
{
$(e.currentTarget).append("<input type='text'>");
}
}

它在 Firefox 或 Chrome 中运行良好,但在 IE8 中运行不佳。

我尝试将bind()更改为live(),但这没有任何效果 - 当我单击列表项时,它只是不执行任何操作(尽管调用了事件处理程序)

如果我将 contentEditable 更改为全部小写的“contenteditable”,则每次单击该元素时,它都会将文本表单附加到该元素,这不是我想要的。

此代码的目的是使表项可编辑。关于如何解决这个问题有什么想法吗?

提前致谢!

最佳答案

TD 元素无法设置为内容可编辑。查看此页面以供引用:http://msdn.microsoft.com/en-us/library/ms537837(v=vs.85).aspx

您可以向单元格添加一个空 div 并使其内容可编辑

关于javascript - jQuery contentEditable 不起作用 - Internet Explorer 8 - 编辑表项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16635933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com