开发者

jquery appendTo elements not honouring css

In the below code, the css style "onred" is not honoured. The css is loaded before this javascript runs ... any ideas? The result is a standard href without the styling.

<script> 
    $.each(parent.j25d169030c6580e7ad7cc5d785cf5fa8.userMenu, function(nam开发者_运维问答e, url) {
if (name == "logout") { 
    $('<li><a id="logout" href="' + url + '" class="onred">' + name + '</a></li>').appendTo('ul#navMenu');
    } else { 
        $('<li><a href="' + url + '" class="onred">' + name + '</a></li>').appendTo('ul#navMenu');
    }                       
    });
</script> 


Your selector may no longer be valid.

Use an inspection tool such as Firebug to see clearly where the element resides and craft your selector to suit.


CSS is always 'honoured'. Doesn't matter which runs first or when.

Execute the code and then inspect the new DOM elements. Is there a class="onred" present? If there is and it's not styled the way you want, it's your CSS that's incorrect.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜