Skip to content

Instantly share code, notes, and snippets.

@garyharan
Created December 11, 2009 18:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save garyharan/254392 to your computer and use it in GitHub Desktop.
$('p[time]').live('mouseover', function() {
var insertion = $(this);
var insertionTime = insertion.attr('time');
var timeSpan = insertion.find('span.time');
if (timeSpan.length) {
timeSpan.show();
} else {
var date = new Date();
date.setTime(insertionTime * 1000);
// determine how you want to format your time stamp here
$('<span/>')
.addClass('time')
.css({
'float': 'right',
'background-color': '#FFF',
'padding': '1px 5px 1px 5px',
'font-size': '0.8em',
'-moz-border-radius': '3px',
'-webkit-border-radius': '3px',
'border-radius': '3px'
})
.html(date.toString())
.appendTo(insertion);
}
}).live('mouseout', function(){
$(this).find('span.time').hide();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment