1.0.0 • Published 8 years ago

jquery.contenttitle v1.0.0

Weekly downloads
2
License
GPL-3.0+
Repository
github
Last release
8 years ago

jquery.contenttitle

Setup input fields\elements that have their title as content. Much like the HTML5 placeholder functionality - but jQuery powered.

  • If content empty - reset to title
  • If content not empty - leave it untouched
  • If content is title, on focus - empty the field

Additional features:

  • Setup multiple elements at once
  • Adds a class when the title is displayed. For example for displaying the title in a different color.
  • Works for <input>, <select>, <textarea> and maybe others
  • If the title attribute is used, the browser automatically displays a tooltip for it on hover.

Dependencies

  • jQuery

Example usage

Html

<input title="search..."/>
<input title="type here..."/>

Javascript

$("input").contentTitle()

Options

$(selector).contentTitle({
  optionName: optionValue, ...
})
optionNamedescriptiondefault value
title_attributeuse this attribute to set the content title"title"
titleuse this text as content titlefalse
title_selectorselector to get the content title from html element contentfalse
title_classclass to be used if the content title is displayed"contentTitle"

License

GPL version 3 or later