実現したいこと
google.mapsのinfowindowに関連する要素をjqueryで操作したい。
どうかご指導お願いします。
問題
<style></style>で操作できるが、jqueryでは操作できない。具体的には、要素の削除、背景色の設定などの操作
対象とする要素
<div class="gm-style-iw-t::after>
と
<div class="gm-style-iw-d>
コード
jquery
1<script> 2 var infoW = new google.maps.InfoWindow({ 3 content:'<div id="comment">' + str +'<div>' 4 }): 5 google.maps.event.addListenerOnce(map,"idle",function(){ infoW.open(map,marker); }); 6 7 var iw_t_after = $('.gm-style-iw-t::after'); 8 iw_t_after.remove(); 9 // iw_t_after.css({'cssText':'background-color:#aaa !important'}); など 10 11 var iw_d = $('.gm-style-iw-d'); 12 iw_d.css({'cssText':'background:#aaf !important'}); 13</script>
下記のように<style>に設定すると反映される
<style> .gm-style-iw-d {background:#aaf !important} .gm-style-iw-t::after { background:#aaf !important} </style>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/08 04:25