I would just like to know what $(this)
refers to when you use it within a function called by a button.
Is it referring to the button element or is it referring to the function itself.
Code example:
<div>
<span class="fileError"></span>
<input type="file" class="understanding" />
</div>
<script>
$('.understanding').click(function(){
$(this).closest('div').find('span.fileError').html('My brain needs help');
});
</script>
Things I have tried to change the html of my span
$(this).prev('span.fileError').html();
$(this).closest('div').find('span.fileError').html();
$(this).closest('div').find('span.fileError').text();
Links I have tried:
Jquery:find input field closest to button
Understand javascripts 'this' with clarity
Finding Closest p tag to the clicked button
I have look at more places, thought I would just show those I found most informing. What do I need to do here and to what $(this)
is referring within the function?