<polygon id="triangle" fill="none" stroke="#EB9381" stroke-miterlimit="10" points="66.233,110.916 114.721,83 66.233,55.083 "/>
<g id="rectangle">
<rect x="90.908" y="64.82" fill="none" stroke="#EB9381" stroke-miterlimit="10" width="5" height="38" />
<rect x="71.908" y="64.82" fill="none" stroke="#EB9381" stroke-miterlimit="10" width="5" height="38"/>
</g>
这是我的 jquery.我想做的是在单击时隐藏三角形 id="triangle",并显示矩形。我尝试过悬停效果,它确实有效。但使用点击选项却没有,我不知道为什么。
function hoverplayer()
{
$('#rectangle').hide();
$('#cercle_tourne').click(
function()
{
$('#triangle').hide();
},
function()
{
$('#rectangle').show();
}
);
}
最佳答案
您可以尝试以下方法!但请确保“cercle_tourne”是一个容器或按钮。单击它时,它将显示控件(三角形),第二次单击时,它将隐藏它。
$('#cercle_tourne').click(function(){
if($('#triangle').css('display') == 'none'){
$('#triangle').show();
}else{
$('#triangle').hide();
}
});
希望以上内容对您有所帮助。
关于jquery - 隐藏和显示 div onclick svg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31990050/