Map*_*rja 4 html css jquery dom
我不太了解jQuery所以我不知道如何添加CSS内联.这是我的代码:
<div class="gm-style-iw" style="top: 9px; position: absolute; left: 15px; width: 23px;">
<div style="display: inline-block; overflow: hidden; max-height: 330px; max-width: 176px;">
<div style="overflow: auto">
<div id="iw-container">
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我想更改max-width第二个div并添加overflow: none到上面的div #iw-container.
我尝试了这个,但它不起作用:
var iwOuter = $('.gm-style-iw');
iwOuter.children().css({max-width:'250px !important'});
iwOuter.children().children().css({overflow:'none'});
Run Code Online (Sandbox Code Playgroud)
编辑我想自定义infowindow谷歌和我对于更改max-width和溢出的值很重要....我认为你的代码可能是好的,但我不明白为什么不工作...
在jQuery中你可以这样做:
$('.gm-style-iw > div').css('max-width', "250px !important");
$('#iw-container').parent().css('overflow', 'none');//css wasn't valid here
Run Code Online (Sandbox Code Playgroud)
使用> div意味着它只获得第一个div,如果你想要所有的divs max-width,请使用:
$('.gm-style-iw').children().css('max-width', "250px !important");
Run Code Online (Sandbox Code Playgroud)
使用该.parent()函数意味着它只获得所选元素的父元素.它更清晰,更容易阅读,写作也更短.