Passa Parâmetro usando setTimeout Function

by Jothaz

HTML

<input type="button" title="Olá, mundo!" value="Exibe Alert em 2 segundos." />

CSS

input {
    display: block;
    width: 15em;
    margin: 50px auto;
    padding: 1em 0;
}

JavaScript

$('input').click(function () {
    var that = $(this);
    setTimeout(function() { alertMsg(that); },2000);
});
function alertMsg(x) {
    var message = x.attr('title');
    alert(message);
}