Skip to content

Instantly share code, notes, and snippets.

@tomhodgins
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomhodgins/41138c7f7ed9d260071f to your computer and use it in GitHub Desktop.
Save tomhodgins/41138c7f7ed9d260071f to your computer and use it in GitHub Desktop.
Display an input's placeholder="" text as a Bootstrap Tooltip on :focus of non-empty form inputs. See this in action at: http://jsfiddle.net/tomhodgins/LEz3Z/2
// Display placeholder="" text as tooltip for :focused, non-empty inputs
$('form input').blur(function() {
var inputVal = $(this).val(),
titleText = $(this).attr('placeholder');
if ( inputVal != '' ) {
$(this).tooltip({
title: titleText,
trigger: 'focus',
container: 'form'
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment