How do i change Background color of textbox when onfocus?

后端 未结 5 1932
栀梦
栀梦 2021-01-16 05:31

i tried this code but its not working.. when i on-focus textbox it shows error

   function ChangeBgColor(obj, evt) 
    { 
            if(evt.type==\"focus\"         


        
5条回答
  •  情歌与酒
    2021-01-16 06:11

    Yep, you should try this javascript code to change the background color for this element:

      var obj = document.getElementById("yourId");
      obj.onfocus = function() {
        obj.style.backgroundColor = 'red';
      }
    

    Now you can change whatever color you want

提交回复
热议问题