Skip to content

Instantly share code, notes, and snippets.

@tubiz
Created October 22, 2013 16:54
Show Gist options
  • Save tubiz/7104154 to your computer and use it in GitHub Desktop.
Save tubiz/7104154 to your computer and use it in GitHub Desktop.
<div class="fake-input" data-input="Input1" style="background: url('/img/blabla.jpg');">Select your file</div>
<div class="fake-input" data-input="Input2" style="background: url('/img/blabla.jpg');">Select your file</div>
<div class="fake-input" data-input="Input3" style="background: url('/img/blabla.jpg');">Select your file</div>
<input id="Input1" type="file" style="display:none" />
<input id="Input2" type="file" style="display:none" />
<input id="Input3" type="file" style="display:none" />
<script type="text/javascript">
$(document).on('click', '.fake-input', function(e) {
console.log($('#' + $(this).data('input')));
$('#' + $(this).data('input')).click();
});
$(document).on('change', 'input[type="file"]', function() {
$('[data-input="' + $(this).attr('id') + '"]').text($(this).val());
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment