Skip to content Skip to sidebar Skip to footer

Jquery, Convert Title To Slug

I have a PHP script that does the following: It takes a string, for example, 'This is a Great Blog Post, #1!', and returns the following string, 'this-is-a-great-blog-post-1'. I'm

Solution 1:

Or you could write your own version in about 45 seconds:

var str = "This is a Great Blog Post, #1!";
str = str.replace(/[^a-zA-Z0-9\s]/g,"");
str = str.toLowerCase();
str = str.replace(/\s/g,'-');
document.write(str);

// outputs "this-is-a-great-blog-post-1"

Solution 2:

Theres a plugin for that! :)


Solution 3:

Try this one slugit-jquery, it has decent multilanguage support.


Post a Comment for "Jquery, Convert Title To Slug"