RYAN
RYAN

Reputation: 155

How to directly type into a button?

There are a lot of buttons in my HTML. And each time when I click on one button, that button is activated (other buttons are deactivated). And I want that, letters can be directly typed onto that specific button like a textbox (type="text"). Is that possible with javascript? Or do I need other things like JQuery, etc?? Thanks!

Upvotes: 1

Views: 79

Answers (3)

prithajnath
prithajnath

Reputation: 2115

You can wrap an input tag around a button tag and style it with CSS so that it merges with your button.

Upvotes: 0

filype
filype

Reputation: 8380

One way is to add an input element inside a button element.

For example:

   <button>
   <input type="text" placeholder="type somthing here" />    
    Send
   </button>

See the working version: https://jsbin.com/lomufaqoxe/edit?html,output

Upvotes: 2

yuriy636
yuriy636

Reputation: 11661

Something like this?

<button contenteditable="true">Foobar</button>

Upvotes: 4

Related Questions