js设置输入框失去光标与光标选中时样式

输入框样式

<script language="javascript" type="text/javascript">

function glb_searchTextOnfocus(obj) {

         if (obj.value == '请输入您想要的作品...')

                   obj.value = '';

         obj.style.color = '#333';

}

function glb_searchTextOnBlur(obj) {

         if (obj.value == '') {

                   obj.value = '请输入您想要的作品...';

                   obj.style.color = '#98BC00';

         } else {

                   obj.style.color = '#333';

         }

}

</script>

<input name="q" type="text" class="searchkey " value="请输入您想要的作品..." onfocus="glb_searchTextOnfocus(this);"  onblur="glb_searchTextOnBlur(this);" maxlength="70" />

原文地址:https://www.cnblogs.com/shy1766IT/p/4726058.html