jquery-highlighttextarea icon indicating copy to clipboard operation
jquery-highlighttextarea copied to clipboard

Highlighting not working properly when setting value of textarea using jquery

Open smita-chougale opened this issue 7 years ago • 1 comments

I have textarea as follows and highlighted word using highlightTextarea: textarea1

$('textarea').highlightTextarea({
     words: ['brand']
})

When I try to set the value of textarea using jquery:

$('textarea').val('changed_value == 9')

again called following method :

$('textarea').highlightTextarea({
     words: ['brand']
})

then output is as follows: textarea2

It is not reseting the mark tag. Only after I try to edit the textarea value by typing, it removes the highlighted mark from background.

smita-chougale avatar Jul 09 '18 13:07 smita-chougale

You can use it dynamicly first need to destroy $('#textarea').highlightTextarea('destroy'); and then reuse it. $('textarea').val('changed_value == 9') $('textarea').highlightTextarea({ words: ['brand'] })

jsfiddle.net/oqLp6p0d/2

mrsoftware avatar Oct 08 '18 12:10 mrsoftware