how to get the "border-color" value of the ".ui-widget-header" class?

0

I'm working on dynamic web pages and I'm mostly working with jQuery and php.

In jQuery is the section of jQuery-ui that elaborates a series of themes that can be modified dynamically. But there are some things that seem bug. Below the explanation:

I change the color of the border

$('.ui-widget-header').css('border-color','#FF0000');

and then I try to see the value

console.log($('.ui-widget-header').css('border-color'));

and it returns "" . Can you tell me the reason?

    
asked by yonomimi 11.05.2017 в 18:26
source

2 answers

0

$('.ui-widget-header') returns an array if it is your only element with that class you can select your first element and then extract the attribute

$('.ui-widget-header[0]').css('border-color');
    
answered by 11.05.2017 в 18:46
0

you're right ... $('.ui-widget-header') returns an array but it is not necessary to remove any element from it to solve this problem. The problem is another, when you assign a value $('.ui-widget-header').css('border-color','#FF0000'); you also assign it to

$('.ui-widget-header').css('border-top-color','#FF0000');

$('.ui-widget-header').css('border-right-color','#FF0000');

$('.ui-widget-header').css('border-bottom-color','#FF0000');

$('.ui-widget-header').css('border-left-color','#FF0000');

and therefore you have to extract the value for these

$('.ui-widget-header').css('border-top-color');

$('.ui-widget-header').css('border-right-color');

$('.ui-widget-header').css('border-bottom-color');

$('.ui-widget-header').css('border-left-color');

    
answered by 11.05.2017 в 22:55