I am working on a custom file input with the following HTML:
<div class="file">
<a>browse<input type="file" name="annex"/></a>
<span class="path">path</span>
</div>
<div class="help">Only PDF files allowed</div>
You can see an online example here: http://codepen.io/mdmoura/pen/qAvDk
PROBLEMS
CSS
- I am not able to vertically align the button (in red) text and the path text (in blue). I tried to apply inline-block and the same padding for both but no luck ... How can I solve it?
JQUERY
I use
var input = $(this);but if I usevar this = $(this);it doesn't work. Why?Using
$('.path').text(label);works ... But I would like to get the span after the :file that I am referencing ... I triedinput.next().text(label);but it does not work. Why?
Thank You, Miguel