Reputation: 6598
I have two variables like this
var X = 200,
Y = 100;
and i want to set the boder-width
of an element with jQuery according to these variables. I tried something like
$('someElement'),css('border-width','X Y')
$('someElement'),css('border-width',X Y)
$('someElement'),css({borderWidth: X Y})
but none of the methods is worked. Any help?
Upvotes: 1
Views: 4690
Reputation: 14348
Try it like this i have added px
and a space between X and Y
var X = 200,
Y = 100;
$('div').css('border-width',X+'px '+Y+'px');
div{
width:100px;
height:100px;
border-color:green;
border-style:solid;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div></div>
Upvotes: 2