This time I will share jQuery Plugin and tutorial about jQuery Plugin To Generate URL Slugs – Slugify, hope it will help you in programming stack.
Slugify is a lightweitht jQuery plugin that provides a simple way to generate human-readable URL slugs from users input.
How to use it:
1. Load the jQuery library and jQuery slugify plugin in the html document.
2 |
< script src = "jquery.slugify.js" type = "text/javascript" ></ script > |
2. Create two input fields to accept users input and output the URL slugs.
1 |
< label for = "title" >Title</ label > |
2 |
< input type = "text" name = "title" value = "" id = "title" > |
4 |
< label for = "slug_input" >Slug</ label > |
5 |
< input type = "text" name = "slug" value = "" class = "slug" > |
3. Call the plugin on the URL slug input field.
1 |
<script type= "text/javascript" charset= "utf-8" > |
2 |
$().ready( function () { |
3 |
$( '.slug' ).slugify( '#title' ); |
Change log:
2015-11-12
- russian translit corrected
2014-10-07
- Fixed edge case when slug both begins and ends with a –
This awesome jQuery plugin is developed by pmcelhaney. For more Advanced Usages, please check the demo page or visit the official website.