Finding text using javascript widget

I am creating a widget for an application that creates a search entry and searches for text from a div. The widget creates an item, and when the user starts the preview, the search is active and he can search for text.

After the widget is created and created input

, when I try to search, the Chrome console says that searchTxt() is not a function

.

The goal is to pass the value of the input to the function searchTxt

, find the text inside the canvas div and highlight it. But I can't even get it back in the console.log.

Any suggestions? Thanks in advance for any help.

Demo

+3


source to share


1 answer


OK, edited my answer and corrected your demo fiddle.

  • Your onclick button is called search()

    , there was no search.
  • You have to define your function window.funcname = function(){ ... }

    because jsfiddle wraps this code on load.


So I switched your onclick to a searcTxt call and created the function correctly and it works. I also changed it to warning instead of console.log.

I don't know what the other javascript function is, but the code that makes sense now works.

+3


source







All Articles