Howto Place cursor at beginning of textarea

The jQuery way:

$('textarea[name="mytextarea"]').focus().setSelectionRange(0,0);

Pass a reference to your textarea to this JS function.

function resetCursor(txtElement) { 
    if (txtElement.setSelectionRange) { 
        txtElement.focus(); 
        txtElement.setSelectionRange(0, 0); 
    } else if (txtElement.createTextRange) { 
        var range = txtElement.createTextRange();  
        range.moveStart('character', 0); 
        range.select(); 
    } 
}

Depending on your needs, a simpler Javascript version is:

document.querySelector("textarea").focus(); //set the focus - cursor at end
document.querySelector("textarea").setSelectionRange(0,0); // place cursor at start

You can't just string them together either, to get rid of the double querySelector - not sure why.