jQuery Slugify Plugin Demo




Your URL is http://xxx.com/.

$('.slug').slugify('#title');

The plugin takes one option, slugFunc, a callback function that lets you customize how slugs are created. slugFunc() takes two arguments. The first is a selector for the input field to be translated to a slug. The second, optional argument is the original slugFunc(), which you can use as a base.

var pigLatin = function(str) {
  return replace(/(\w*)([aeiou]\w*)/g, "$2$1ay");
}

$('#pig_latin').slugify('#title', {
    slugFunc: function(str, originalFunc) { return pigLatin(originalFunc(str)); } 
  }
);