How can I add an unremovable prefix to an HTML input field?

前端 未结 16 1428
猫巷女王i
猫巷女王i 2020-12-13 04:23

Using jQuery, how can I add a default value of http:// into an input field that can’t be removed, but that still allows you to type a URL after it?

Defa

16条回答
  •  长情又很酷
    2020-12-13 05:02

    This is just me playing around, but you can make a fake extension of the textbox. This example basically chops off the left border of the textbox and concatenates a fake textbox to the left.

    Works only in Chrome AFAICT. You will have to add conditional stylesheets for each browser if you decide on this method.

    http://jsfiddle.net/G9Bsc/1/

提交回复
热议问题