[Js/jquery] Jquery tagsinput application in h5 mail client

Source: Internet
Author: User

Summary

Recently has been tossing the mail H5 application, in order to ensure that the pc,ios,android end can be used, so the use of H5 page embedded in the app's WebView.

Page

The UI is probably like this

Jquery tagsinput Download: http://xoxco.com/projects/code/tagsinput/

First introduce JS and CSS

Input box

<name= "tags " id= "tags"  value= "Wolfy,wolfy2"  />

The above input box has the default value, you can call the Tagsinput method directly, make it into tags

$ (' #tags '). Tagsinput ();

If you want to add auto-completion, you can add the following parameters

$ (' #tags '). Tagsinput ({autocomplete_url: ' Http://myserver.com/api/autocomplete '});

You can add and remove tags by addtag and Removetag methods

$ (' #tags '). Addtag (' foo '); $ (' #tags '). Removetag (' Bar ');

You can add more than one tag at a time by using the following method

$ (' #tags '). Importtags (' Foo,bar,baz ');

Note: If the method is passed in empty, the input content is emptied.

You can tell if a tag already exists

if ($ (' #tags '). Tagexist (' foo ')) {...}

If you wish to have additional actions after adding or deleting, the plugin also provides a callback function for adding and removing.

    $ ("#tags"). Tagsinput ({////    ' autocomplete_url ': Url_to_autocomplete_api,    ///    ' AutoComplete ': {option:value, option:value},    //    ' height ': ' 100px ',    //    ' width ': ' 300px ',    //    ' Interactive ': true,    //    ' DefaultText ': ' Add a tag ',    //    ' Onaddtag ': function (tag) {    //        Console.log (' added ', tag);    },    //    ' Onremovetag ': function (tag) {    //        console.log (' removed ', tag);    },    //    ' OnChange ': function (tag) {    //        console.log (' changed ', tag);    },    //    ' delimiter ': [', ', '; '],   //or a string with a single delimiter. Ex: '; '    ' Removewithbackspace ': true,    //    ' Minchars ': 0,    //    ' Maxchars ': 0,//if not provided there is no limit    //    ' Placeholdercolor ': ' #666666 '    //});

[Js/jquery] Jquery tagsinput application in h5 mail client

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.