Jquery 当我们单击div打开其他打开的div时,如何更改图像
我正在使用上面的代码来显示一个打开时带有向下箭头的div(cl-bt.png)。当我们单击其他div时,打开的div应该关闭,图像应该更改为右箭头(cl-rt.png)。但是它只是关闭div,而不是更改图像。请在这方面帮助我。什么是Jquery 当我们单击div打开其他打开的div时,如何更改图像,jquery,html,css,Jquery,Html,Css,我正在使用上面的代码来显示一个打开时带有向下箭头的div(cl-bt.png)。当我们单击其他div时,打开的div应该关闭,图像应该更改为右箭头(cl-rt.png)。但是它只是关闭div,而不是更改图像。请在这方面帮助我。什么是不(之前的$('#'+id+'img')。attr('src','cl-rt.gif').show();?它将显示除当前id以外的右箭头(cl-rt),但我不知道它的使用方式是否正确? ## html ## <span class="disp">
不(
之前的$('#'+id+'img')。attr('src','cl-rt.gif').show();
?它将显示除当前id以外的右箭头(cl-rt),但我不知道它的使用方式是否正确?
## html ##
<span class="disp">
<a href="javascript:void(null);" onClick="toggleView('faq1');">
<img src="cl-bt.gif" id="faq1img" />Estoy interesado en una propiedad</a>
</span>
<div id="faq1" class="est">Comuníquese directamente con el anunciante usando el formulario <b>"Solicitar más Información"</b> del anuncio que le interesa.
</div>
<span class="disp">
<a href="javascript:void(null);" onClick="toggleView('faq2');"/>
<img src=cl-bt.gif" id="faq2img" />Quiero vender o alquilar mi propiedad</a>
</span>
<div id="faq2" class="est">Anúnciese Gratis.
<a href="#" style="color:#EF6000; font-weight:bold">Click aquí</a>
</div>
<span class="disp">
<a href="javascript:void(null);" onClick="toggleView('faq22');">
<img src="cl-bt.gif" id="faq22img" />¿Como puedo destacar mi anuncio?
</a>
</span>
<div id="faq22" class="est">
<a href="http://www.google.com" style="color:#EF6000; font-weight:bold">Más información sobre Anuncios Destacados
</a>
</div>
## javascript ##
function toggleView(id) {
if ($('#' + id).css('display') == 'none') {
$('#' + id + 'img').attr('src', 'cl-bt.gif');
$('#' + id).show();
$(".est").not($('#' + id)).hide();
not($('#' + id + 'img')).attr('src', 'cl-rt.gif').show();
} else {
$('#' + id + 'img').attr('src', 'cl-rt.gif');
$('#' + id).hide();
}
return true;
}
.disp{ display:block; clear:both; margin-bottom:5px;}
.est
{
display:block;
border:1px dotted #000;
background:#FFF;
padding:5px;
clear:both;
margin-bottom:5px;
}