开发者

How do I set this div's style in the style sheet?

开发者 https://www.devze.com 2022-12-23 00:06 出处:网络
开发者_StackOverflow社区<style type=\"text/css\"> #[\':0:adId\'] {/* this does not work */ background:red;
开发者_StackOverflow社区<style type="text/css">
   #[':0:adId'] {        /* this does not work */
      background:red;
   }
</style>

<div id=":0:adId">Loading...</div>

Google Maps use this id format. How do i set the style?


You simply need to escape the : with a \:

<style type="text/css">
    #\:0\:adId {
        background:red;
    }
 </style>


You could do this with a attribute selector, like so:

div[id=":0:adId"] {
    background: red;
}

This will not work in all browsers(you guessed IE), so you might have to include some javascript to do the trick there:

$('div[id=":0:adId"]').css({
    background: '#FFF'
});

(Uses jQuery)

0

精彩评论

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

关注公众号