I am trying to focus on a textarea in my HTML. The textarea has a function to submit on enter.
<form id = "msgform" method="POST" >
{% csrf_token %}
<textarea id = "msg" name = "msg" > </textarea>
</form>
I have a function that focuses on the textarea on page load, and I want to do the same when my ajax call returns success
$.ajax({
type:'POST',
url:'{{request.path}}',
data:{
value:$('#msg').val(),
csrfmiddlewaretoken: '{{ csrf_token }}',
},
success:function(data){
$( "#Wrap" ).load(window.location.href + " #M" );
('#msg').focus()
}
})
The rest of the Ajax call works fine, but the ('#msg').focus() does not work. What could be causing this?