web-profile

jQuery .css()

jQuery .css() gets or sets the css style property for the target element;

js:

$('.target').css('background-color', 'yellow').append(' <span class="label label-info">set background-color</span>');

$('.target2').css({
    'background-color': 'yellow',
    'font-weight': 'bold'
}).append(' <span class="label label-info">set background-color and font-weight</span>');

$('.target3').append(' bg-color:' + $('.target3').css('background-color')).append(' <span class="label label-info">get background-color</span>');​

html:

<div class="target">.target</div>

<div class="target2">.target2</div>

<div class="target3">.target3</div>

css:

.target3 {
    background-color: #afa;
}​

Leave a Reply

Your email address will not be published. Required fields are marked *