我有一个GAS Web App,其中包含一个带有<tr contenteditable="false" id="pmlist'+ index+'">行标记的表。我想要创建一个事件来允许编辑内容,并使边框刻度从1px更改为3px,并且在行的长度上在黑白之间波动(以指示此行正在被编辑),然后当用户单击突出显示的行之外的任何地方时,contenteditable被设置回false,边界像素被设置回1px,颜色被设置回静态白色。
这就是我到目前为止所知道的:
HTML:
$(document).on("click","tr", function(e){
e.preventDefault();
$(e.currentTarget).attr("contenteditable", "true");
// border: 1px solid black;
// $('#'+e.currentTarget.id).css("border", "3px solid");
for (var i = 0; i < 3; i++ ) {
$('#'+e.currentTarget.id)
.animate( { backgroundColor: "#f00" }, 2000 ) //I need to change this to border color and thickness
.animate( { backgroundColor: "transparent" }, 2000 );
}
//Then create an event to revert editions to normal : bordercolor: black,
//borderthickness: 1px,
});我很感谢你的帮助,如果不能提供解决方案,我也会感谢相关文档的指导。
发布于 2019-01-30 05:02:23
你不能不使用插件。
在http://api.jquery.com/animate/中,“所有动画属性都应该动画化为单个数值,除非如下所述;大多数非数值属性不能使用基本的jQuery功能(例如,宽度、高度或左侧可以动画,但背景色不能动画,除非使用jQuery.Color插件)”,还考虑到“不完全支持速记属性(例如字体、背景、边框)”。
您需要一个插件来实现边框颜色转换“$.animate()忽略边框颜色属性”方法。例如,尝试这个:https://bitstorm.org/jquery/color-animation/ 2.7kB minified。
所以要包含这个插件
脚本src="//cdn.jsdelivr.net/jquery.color-animation/1/mainfile“
定义css上的边框规则
并在for循环上执行您想要的for属性的动画:
.animate({borderColor:'#f00'},2000) .animate({borderWidth:‘3px’},2000)
https://stackoverflow.com/questions/54425424
复制相似问题