Jump to content

simple javascript checking for border styling and then removing it>


Recommended Posts

So simple I'm sure.  I need help with the syntax for the stuff below in between the asterisks...

 

if (*any element on the page has a border style* = '1px solid red') { //see if any elements have a border
*set the style of those elements border*  = 'none';  //take the border styling away
} 
document.getElementById('box'+val).style.border = '1px solid red';  //set a specific element to  have border styling again

 

The 3rd line of code works fine, but I need to get the IF statement working.  I tried using "document.style.border" but that didn;t work  :-\

 

Can anybody help?

An easier way to ask this might be...

 

Using Javascript, how do I search the page for ANY elements with a certain CSS style (for example "color: blue") and change them to red?  There could be one, there could be many.

 

I think my basic code structure above is correct, but need help with exact syntax.

 

 

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.