Skip to content

Instantly share code, notes, and snippets.

@hilukasz
Created May 9, 2012 13:31
Show Gist options
  • Save hilukasz/2644515 to your computer and use it in GitHub Desktop.
Save hilukasz/2644515 to your computer and use it in GitHub Desktop.
//not even sure if I can do this? should I declare each var for each value?
var newSalesPageInputs = [$newSaleAddress = $('#newSaleAddress'),
$newSaleAddress = $('#newSaleAddress'),
$newSaleTitle = $('#newSaleTitle'),
$newSaleDescription = $('#newSaleDescription'),
$newSaleSummary = $('#newSaleSummary'),
$newSaleItems = $('#newSaleItems')];
for (var i = 0; i < newSalesPageInputs.length; i++) {
alert(i);
$newSalesPageInputs[i].focus(function () {
$newSalesPageInputs[i].attr('data-value', $newSalesPageInputs[i].val());
$newSalesPageInputs[i].val('');
});
$newSalesPageInputs[i].blur(function () {
if ($newSalesPageInputs[i].val().length === 0) {
$newSalesPageInputs[i].val($newSalesPageInputs[i].attr('data-value'));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment