我有一个想要展开/收缩的div,但链接除外。我有以下代码,它可以工作,但缺少异常。确保div "expandablediv“中的所有元素和区域的最有效方法是使用jquery进行扩展/压缩,但元素除外。
$("#expandablediv").click(function () {
if ($("#withinexpandlediv").is(":hidden")) {
$("#withinexpandlediv").fadeIn(50);
}
else {
$("#withinexpandlediv").fadeOut(50);
}
});HTML代码:
<div id="expandablediv" >
<div class="ddImage">
<img src="rightArrow.png" alt="Title">
</div>
<div class="ddText">
Title
</div>
<div id="withinexpandlediv" >
Text contains one or more <a href="mailto:email@links.com"> email links.</a>
</div>
</div>发布于 2013-07-23 04:48:24
就像这样
if(!$('#expandablediv').children().has('a')){
// handle expandsion/contraction here
}有关更多详细信息,请查看此链接:jQuery .has()
https://stackoverflow.com/questions/17797038
复制相似问题