jQuery: textarea default value disppear on click

前端 未结 8 1184
Happy的楠姐
Happy的楠姐 2021-02-04 16:40

I want a textarea with some default text. When the user clicks in the textarea the default text should be deleted. How can I make value of a textarea disappear on click?

<
8条回答
  •  日久生厌
    2021-02-04 17:35

    You can accomplish this even without JavaScript by using placeholder attribute.

    But you should be aware that not every browser supports it yet. In this case you can use for instance this plugin: http://plugins.jquery.com/project/input-placeholder

提交回复
热议问题