-
Couldn't load subscription status.
- Fork 0
ProtoString cleanId() Method
Seth Clydesdale edited this page May 23, 2015
·
2 revisions
Cleaning a string of text, so that it can be used as a valid identifier.
var id = 'my identifier!'.cleanId(); // returns 'my-identifier'
var node = document.createElement('DIV');
node.id = id; // apply the cleaned string as the IDThe cleanId method can be used to clean a string of text, so that it can later be used as the id or href attribute of an element. This method removes characters considered "illegal." All alphabetical characters are kept, as well as dashes and underscores, whereas whitespace is converted to a dash and illegal characters are stripped.
String.cleanId();Home • History • ProtoString • Created by Seth Clydesdale