Putting cursor at end of textbox in javascript

Viewed 17022

I have a textbox that when I put on focus I want the cursor to goto the end of the textbox.

The solution that keeps coming up is just

this.value = this.value

I have tried this with a simple method onclick:

function InputClicked(element) {
    element.className = "inputfocused";
    element.value = element.value;
}

but the strange this with this, it seems to goto the end and then jump to the start of the textbox.

3 Answers
Related