javascript - How do I get this JQuery to target & shorten URL's in a string? -


I'm just starting with JQuery.

My question: I want to know what I can do to modify this code below to shorten the long URL, but ignore anything that is not a URL?

My problem: This code fragment targets everything in DIV ('work-overflow'). Although I only need this to affect the url based on protocol (.) In that DIV. The sentences on both sides of the URL are

  $ (document) .ready (function () {$ (". Task-overflow: in ('http: //')") .each (function () {$ (this ) .text ("http: // ...");});});  

Any help would be appreciated, thanks

My Awnser After I read my questions better, try it:

  $ (document) .ready (function () {$ (". Task-overflow: in ('http: //')") .each (function () {Var self = $ (this), txt = self.text (); txt = txt.replace (/ (http [s] *: [\ / \\] {2}) [^ \ S] * / g, '$ 1 ...'); self.text (txt);});});  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -