0

Is it possible to find the matching parenthesis on the same page and highlight both.
eg...

function foo(){
//test
};

So when I click on the '{' I want to be able to find the corresponding parenthesis '}' and highlight both on the webpage.


how can I achieve this using javascript/jQuery?

Gautam Jain
  • 651
  • 8
  • 16
  • Whatever syntax/language you're showing on the page, you'll need a parser for it if the data could be more than your simple example. Furthermore, what needs to be done will depend on the markup in the page itself. –  Oct 23 '16 at 17:15

1 Answers1

0

To find those chars, use:

var a = str.indexOf("{");

Then use:

var b = str.indexOf("}", a);

Finally use How to highlight text using javascript

Community
  • 1
  • 1
iazaran
  • 196
  • 1
  • 6
  • 17