今天要做的效果是:
(1)當(dāng)輸入框顯示的文字是“請(qǐng)輸入文字”索烹,輸入框獲得焦點(diǎn)時(shí)提示語(yǔ)消失弱睦。
(2)當(dāng)輸入框內(nèi)容為空,失去焦點(diǎn)時(shí)况木,輸入框會(huì)出現(xiàn)提示語(yǔ)“請(qǐng)輸入文字”旬迹。
(3)當(dāng)輸入框內(nèi)有非提示語(yǔ)內(nèi)容求类,失去、獲取焦點(diǎn)時(shí)仑嗅,輸入框內(nèi)容不變。
示例
步驟
設(shè)置輸入框OnFocus(獲得焦點(diǎn))鸵贬、OnLostFocus(失去焦點(diǎn))事件脖捻。
1.設(shè)置OnFocus事件:
設(shè)置條件
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?設(shè)置事件
2.設(shè)置OnLostFocus事件
設(shè)置條件方法同OnFocus設(shè)置條件地沮。
設(shè)置事件
3.F5預(yù)覽吧~