JavaScript IDify


/ Published in: JavaScript
Save to your folder(s)

This prepends a `#` if it's not already there. Useful when doing jQuery selectors.


Copy this code and paste it in your HTML
  1. Evan.idify = function(id) {
  2. if (id[0] !== '#') return '#' + id;
  3. return id;
  4. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.