admin管理员组文章数量:1318154
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 not exactly a Jquery expert, that's why I'm asking this question. Does someone know of a Jquery (or Javascript, for that matter) script that will do the same thing as my script? Thanks in advance.
Will
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 not exactly a Jquery expert, that's why I'm asking this question. Does someone know of a Jquery (or Javascript, for that matter) script that will do the same thing as my script? Thanks in advance.
Will
Share Improve this question asked Feb 18, 2010 at 21:24 willbeelerwillbeeler 6891 gold badge13 silver badges26 bronze badges3 Answers
Reset to default 15Or 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"
Theres a plugin for that! :)
Try this one slugit-jquery, it has decent multilanguage support.
本文标签: JavaScriptJQueryConvert Title to SlugStack Overflow
版权声明:本文标题:javascript - Jquery, Convert Title to Slug - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739295204a2156873.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论