の <object>
要素は、同様の方法で別のドキュメントを作成します <iframe>
.
同じドメインからのものであるため、次を使用してそのドキュメントにアクセスできます jQueryの contents
方法[^]. ただし、最上位ドキュメントに対して実行される jQuery セレクターは、ネストされたドキュメント内の要素を選択できません。
jQuery("object stop")
はゼロの一致を返します。 stop
は現在のドキュメントの一部ではありません。 しかし jQuery("object").contents().find("stop")
動作するはずです。
jQuery('.test').on('click', function () {
jQuery('object').contents().find('stop').each(function () {
var color = jQuery(this).css('stop-color');
if (color === 'rgb(77, 77, 77)') {
jQuery(this).css('stop-color', '#ff0000');
}
});
});
<object data="Img/PumpStation/Pump.svg" type="image/svg+xml" id="alphasvg1111"></object>
【解決方法】 タグ内の Jquery select SVG 要素