views:

50

answers:

1

Hi! How would be correct to get the font elements in the table with color="#0000cc" and drop after each the new img Element? I'm trying to do like that, but it doesnt' work

$$('.tdresult font').each(function(el){
    var state=el.get('color');
 if (state.match('#0000cc'))
 {
var newel = new Element ('img' , { 'src' : 'images/case.png' , 'style' : 'float:right; width:5px; height:5px' }).injectAfter(el);
 }
     else {
//
      }
});

P.S.: Yes i know that font elements and color attributes are pretty old standard and i should use span instead, but it's impossible in my case... Although i use xhtml

+1  A: 

You can use the selector with attributes like this:

$$('.tdresult font[color$=0000cc]').each(function(el){
  var newel = new Element ('img' , { 
    'src' : 'images/case.png' , 
    'style' : 'float:right; width:5px; height:5px'
  }).injectAfter(el);
});

Looks like you have to use color$=0000cc to match the end of the color because it won't read the # character. I'm sure there's a way to represent that, I'm just not sure how.

Shawn Steward
thank u, Shawn! It worked great for me!
moogeek