Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can the HTML tag protection stuff be simplified? #7

Open
henrythewasp opened this issue Sep 5, 2013 · 0 comments
Open

Can the HTML tag protection stuff be simplified? #7

henrythewasp opened this issue Sep 5, 2013 · 0 comments

Comments

@henrythewasp
Copy link

I was using this plugin and having some problems with tags not being closed, then I realised that you can use the following to get jQuery to close any open tags for you:

var safeShortString = $('<div/>').html(shortString).html();

So, when the string has to be truncated, just pass the truncated shortString as above and jQuery sorts it out for you and you don't need all that char-by-char parsing code.

I've tested this with jQuery 1.7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant