Search code examples
javascriptjquerytext-editormathquill

How detect mathquill editor to write equation


I am currently making rich text editor with maths equation writing. enter image description here

As per above image you can see yellow marker which is mathquill-editable span. 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. example $('#classname') for write equation from button. Its works fine but problem comes when I add another mathquill-editable span. 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.


Solution

  • 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