gpt4 book ai didi

javascript - 如何检测mathquill编辑器写方程

转载 作者:行者123 更新时间:2023-11-27 23:48:54 25 4
gpt4 key购买 nike

我目前正在制作带有数学方程编写的富文本编辑器。 enter image description here

根据上图,您可以看到黄色标记,它是mathquill-editable跨度。我制作了包含一些数学符号的按钮。我想要的是!!当用户单击按钮时,应在光标位置打印方程。我选择了带有类的 mathquill-editable span。示例 $('#classname') 用于从按钮写入方程。它工作正常,但当我添加另一个 mathquill-editable 跨度时出现问题。当存在多个跨度时,每次单击按钮时,它们的值都会同时在每个类中打印。我如何检测特定跨度处于事件状态并且值将仅打印在光标的跨度上。

最佳答案

这是我为从所有类中找到一个元素而做出的小小的努力。

$(document).ready(function(){  /* when the page has loaded... */
$('.mathquill-editable').click(function(){ /* ...bind click event to .boxSet elements */
$('.mathquill-editable').removeClass('hilite'); /* On click, remove any 'hilite' class */
$(this).addClass('hilite'); /* ...and add 'hilite' class to clicked element */
});
});

DEMO HERE

关于javascript - 如何检测mathquill编辑器写方程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32888407/

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