Page 1 of 1

Can I set the image border color via javascript?

Posted: Mon Mar 11, 2013 5:14 am
by New Mobile Guy

I need to set the image border color dynamically, via javascript.

I can set the border size easily via this code:

theImage.attr('border',3);

But I can't seem to set the color. Setting border-color or a bunch of other things I tried doesn't change it from black.

Help. Thanks!


Can I set the image border color via javascript?

Posted: Mon Mar 11, 2013 5:44 am
by maxkatz

Use something like this:
border:2px solid #021a40;


Can I set the image border color via javascript?

Posted: Mon Mar 11, 2013 12:41 pm
by New Mobile Guy

Hmmm... the 2px is working but the color is not. Here's the exact code I'm using. The border is still black. Is my syntax wrong?

theImage.attr('border','2px solid #0000ff;' );


Can I set the image border color via javascript?

Posted: Mon Mar 11, 2013 1:50 pm
by Maryna Brodina

Hello! Try

codeTiggzi('imgName').css('border', '5px #f0ff10 dashed');/code

you should set css, not attr


Can I set the image border color via javascript?

Posted: Mon Mar 11, 2013 2:17 pm
by New Mobile Guy

That worked. Thanks!


Can I set the image border color via javascript?

Posted: Wed Oct 08, 2014 3:57 am
by Bikram Ray

Code Works like champ. But when I add it to grid it is adding border to the first one only. I am not sure why I have maooed $ to grid.
Bikram


Can I set the image border color via javascript?

Posted: Wed Oct 08, 2014 4:02 am
by Illya Stepanov

Hi -

Could you please specify where and how you're adding this code?