0

I am trying to change a text field's border using javascript

field.style.border='2px solid red';

that's working, then I want to restore the default style of browser after 2 or 3 seconds

I have done something like this

function shine(field){
        field.focus();
        field.style.border='2px solid red';
        setTimeout(function(){
            field.style.border='initial';
        },2000);
    } 

but the attribute initial is not helping.

Is there any way to do it?

Thanks in advance. :)

Arun Xavier
  • 763
  • 8
  • 47

1 Answers1

1

You should just set it to "" as stated in the related question.

element.style.border = ""

This will restore the css value provided.

You can check quick JSBin, I've created

drinchev
  • 19,201
  • 4
  • 67
  • 93
  • thanks, it works :) and excuse me, will IE support this? – Arun Xavier Dec 04 '14 at 11:38
  • 1
    Well, the question was closed as a duplicate already, and the answers in the other question suggest that you should use `''` instead of `null`, especially for IE. – GolezTrol Dec 04 '14 at 11:49