开发者

Mootools - selecting the font element with color matches the pattern and injecting the el after each. How?

开发者 https://www.devze.com 2022-12-09 23:10 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消