New Mobile Guy
Posts: 0
Joined: Tue Jan 29, 2013 9:09 pm

Can I set the image border color via javascript?

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!

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Can I set the image border color via javascript?

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

New Mobile Guy
Posts: 0
Joined: Tue Jan 29, 2013 9:09 pm

Can I set the image border color via javascript?

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;' );

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Can I set the image border color via javascript?

Hello! Try

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

you should set css, not attr

New Mobile Guy
Posts: 0
Joined: Tue Jan 29, 2013 9:09 pm

Can I set the image border color via javascript?

That worked. Thanks!

Bikram Ray
Posts: 0
Joined: Wed May 22, 2013 5:52 pm

Can I set the image border color via javascript?

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Can I set the image border color via javascript?

Hi -

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

Return to “Issues”