简体   繁体   English

如何检测Mathquill编辑器以编写方程式

[英]How detect mathquill editor to write equation

I am currently making rich text editor with maths equation writing. 我目前正在使用数学方程式编写丰富的文本编辑器。 在此处输入图片说明

As per above image you can see yellow marker which is mathquill-editable span. 如上图所示,您可以看到黄色标记,该标记可进行mathquill-editable and i made button with containing some maths symbols. 我做了包含一些数学符号的按钮。 What I want!! 我想要的是!! When user click button than equation should be print at cursor location. 当用户单击按钮时,公式应打印在光标位置。 I selected mathquill-editable span with class. 我在课堂上选择了mathquill-editable范围。 example $('#classname') for write equation from button. 示例$('#classname')用于从按钮写入方程式。 Its works fine but problem comes when I add another mathquill-editable span. 它的工作正常,但是当我添加另一个mathquill-editable跨度时,问题就来了。 When multiple span are there than every time when i click button than their value printed in every class at same time. 当有多个跨度时,比每次单击按钮时,它们的值同时打印在每个班级中。 How I detect particular span is active and value will print on cursor's span only. 我如何检测特定范围是有效的,并且值将仅显示在光标的范围上。

This is my little efforts to find just one element from all class. 这是我从所有班级中只找到一个要素的努力。

$(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 此处演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM