Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change border-bottom color using jQuery?

Tags:

jquery

css

border

How to change the color of the bottom border using jQuery?

like image 366
halocursed Avatar asked Oct 02 '09 12:10

halocursed


3 Answers

to modify more css property values, you may use css object. such as:

hilight_css = {"border-bottom-color":"red", 
               "background-color":"#000"};
$(".msg").css(hilight_css);

but if the modification code is bloated. you should consider the approach March suggested. do it this way:

first, in your css file:

.hilight { border-bottom-color:red; background-color:#000; }
.msg { /* something to make it notifiable */ }

second, in your js code:

$(".msg").addClass("hilight");
// to bring message block to normal
$(".hilight").removeClass("hilight");

if ie 6 is not an issue, you can chain these classes to have more specific selectors.

like image 116
nil Avatar answered Oct 23 '22 17:10

nil


$('#elementid').css('border-bottom', 'solid 1px red');
like image 30
John Boker Avatar answered Oct 23 '22 18:10

John Boker


If you have this in your CSS file:

.myApp
{
    border-bottom-color:#FF0000;
}

and a div for instance of:

<div id="myDiv">test text</div>

you can use:

$("#myDiv").addClass('myApp');// to add the style

$("#myDiv").removeClass('myApp');// to remove the style

or you can just use

$("#myDiv").css( 'border-bottom-color','#FF0000');

I prefer the first example, keeping all the CSS related items in the CSS files.

like image 5
Mark Schultheiss Avatar answered Oct 23 '22 18:10

Mark Schultheiss