I want to set all text boxes border color on the form to red. I tried using
$('*').css('border', 'black');
also
var all = document.getElementsByTagName('*');
for(var i=0;i<all.length;i++)
{
all[i].style.backgroundColor = "Red";
}
Nothing is working for me.
In the CSS file all text boxes
input[type=text], .htmlplusinput {
border: 1px solid #C79988;
padding:1px;
width:120px;
cursor: text;
}
input[type=text]:focus, .htmlplusinput:focus {
border:2px solid #25a3fc;
padding:0px;
}
To start with, the
$('*')selector matches all elements. If you only want text boxes, you’ll want to use$('input:text').Once you have the selector correct, you need to set the colour of the border. If I recall correctly, the correct CSS property is
border-color, so you’d do:Another, potentially better, solution would be to add a class to each of the elements, rather than modifying their
styleproperty, then use a CSS declaration for that class to control the appearance of the border: