CSS
-Tricks
treehouse :
what would you like to learn today?
Web Design
Web Development
iOS Development
Show search box
Search
Search in:
All
Articles
Forums
Snippets
Videos
✕
Home
Forums
Snippets
Gallery
Videos
Almanac
Demos
Lodge
Navigation 'n' Search
Forums
Illustration by Nick Sirotich
Forums
»
JavaScript Jungle
jQuery typing detection
iancoates
Permalink to comment
#
June 2012
Hi,
I'm looking for some jquery code. What I want to achieve is when I'm typing in a textarea and I type
<b>
I want it to automatically add the closing tag. Ideally this would work for any tag.
I'm sorry not to have any code to start with but al my searches have drawn a blank and I'm not too hot with jquery. Anyway, thanks for any help
Ian
iancoates
Permalink to comment
#
June 2012
oops acidentally bolded everything. Should be "everytime i type < b >..." without the spaces
karlpcrowley
Permalink to comment
#
June 2012
Fixed up for ya
I wouldn't recommend starting from scratch with this, it would involve writing a regular expression for every type of html element which somehow ignores any attributes, I'm sure there's plenty out there
Here's a list of editor available using JavaScript
http://en.wikipedia.org/wiki/Comparison_of_JavaScript-based_source_code_editors
I've never used any of them myself but I've heard Ace is the best
http://ace.ajax.org/
Add a Comment
I'm looking for some jquery code. What I want to achieve is when I'm typing in a textarea and I type I want it to automatically add the closing tag. Ideally this would work for any tag.
I'm sorry not to have any code to start with but al my searches have drawn a blank and I'm not too hot with jquery. Anyway, thanks for any help
Ian
I wouldn't recommend starting from scratch with this, it would involve writing a regular expression for every type of html element which somehow ignores any attributes, I'm sure there's plenty out there
Here's a list of editor available using JavaScript
http://en.wikipedia.org/wiki/Comparison_of_JavaScript-based_source_code_editors
I've never used any of them myself but I've heard Ace is the best
http://ace.ajax.org/