Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

highlight text box border color for few seconds?

Tags:

html

jquery

css

Hi i want to highlight a text box border color for few seconds , afterwards i want to change it back to white color. is ther a way for addClass function to specify time also. Any other way ?tried with http://jsfiddle.net/RW2s4/7/ not working

like image 830
Rosh Avatar asked May 24 '12 09:05

Rosh


People also ask

How do you make a text box border red in validation fails?

If you have only one textbox and id is known to you , you can use the @PanzerKadaver solution. Otherwise i would suggest to return in the json it self the ids of the textboxes which you want to make the red . Then loop through it and add the error class on the client side.

How do you highlight a text box in HTML?

Highlight using the HTML5 <mark> tag If you are working on an HTML5 page, the <mark> tag can quickly highlight text. Below is an example of the how to use the mark tag and its result. If your browser supports the <mark> tag, "highlighted text" should have a yellow background.


1 Answers

This little script added the class 'highlight' for two seconds to the input field:

$('#text').change(function() {
    var jElement = $(this);
    jElement.addClass('highlight');
    setTimeout(
        function() { jElement.removeClass('highlight'); },
        2000
    );
});

Also see this example.

Or here the combination of your and mine solution.

like image 101
scessor Avatar answered Oct 17 '22 08:10

scessor