0

If I have a input box with value 'jklmnop', how would I go about removing 'k' using javascript?

I was thinking something along the lines of:

<input type='text' id='letters' value='jklmnop'/>
<button onclick='removeK()'>Remove</button

Using this javascript:

function removeK() {
    document.getElementById('letters').value.replace('k','');
    }

Can anyone tell me why this doesn't work? And if so, what would I need to do to make it work?

Thanks :)

J.Brooker
  • 109
  • 5

1 Answers1

2

You aren't setting the value.

var l = document.getElementById('letters');
l.value = l.value.replace('k','');
C B
  • 12,482
  • 5
  • 36
  • 48