How would be corre开发者_JAVA百科ct 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
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.
精彩评论