讲述textarea标签属性 textarea设置默认值变灰


讲述textarea标签属性 textarea设置默认值变灰

文章插图
完美解决textarea输入框提示文字 , 必须添加默认内容
<input/>有placeholder标签 , 可以添加提示文字  , 但是<textarea>没有;所以提出以下解决方案
1.
<textarea id="t" rows="20" cols="20"></textarea><script>var t = document.getElementById('t');let aaa = '项目需求概要';t.innerHTML=aaa;t.onfocus = function(){if(this.value =https://www.520longzhigu.com/diannao/= aaa){this.value =''}}; t.onblur = function(){if(this.value =https://www.520longzhigu.com/diannao/=''){this.value = https://www.520longzhigu.com/diannao/aaa;}};2.
<textarea cols="50" rows="5" id="textarea" onfocus="if(valuehttps://www.520longzhigu.com/diannao/=='限100字'){value=''}" onblur="if (value https://www.520longzhigu.com/diannao/==''){value='https://www.520longzhigu.com/diannao/限100字'}">限100字</textarea> 3.
这你需要把id=’note’的div 定位到textarea上面
<div style="position:relative;"> <textarea class="textarea" onfocus="document.getElementById('note').style.display='none'" onblur="if(valuehttps://www.520longzhigu.com/diannao/=='')document.getElementById('note').style.display='block'"></textarea> <div id="note" class="note"> <font color="#777">项目需求概要</font> </div> </div>4.
<script type="text/javascript">//提示内容:(默认值) var c = '请输入内容:';function on_focus(obj){ obj.value = https://www.520longzhigu.com/diannao/obj.value==(!!arguments[1]?arguments[1]:c)?'':obj.value; }function on_blur(obj){ obj.value = obj.valuehttps://www.520longzhigu.com/diannao/==''?(!!arguments[1]?arguments[1]:c):obj.value; }</script>


    以上关于本文的内容,仅作参考!温馨提示:如遇健康、疾病相关的问题,请您及时就医或请专业人士给予相关指导!

    「四川龙网」www.sichuanlong.com小编还为您精选了以下内容,希望对您有所帮助: