我让我的Divs切换正常,但我也试图让img同时切换,到目前为止,我没有太多关注图像交换。即时通讯使用剃须刀foreach使ID unqiue,所以他们不会改变图像和扩展
继承我的代码: -
<script>
$(document).ready(function () {
$("#@quote.First().Quote.QuoteNo-title").click(function () {
$("#@quote.First().Quote.QuoteNo-quote").toggle(
function () {
var img = "@quote.First().Quote.QuoteNo-img";
if ($(img).attr("src") == "~/Images/minus.png") {
$(img).attr("src", "~/Images/plus.png");
} else {
$(img).attr("src", "~/Images/minus.png");
}
}
);
});
});
</script>
<div class="quote-title" id="@quote.First().Quote.QuoteNo-title"><img id="@quote.First().Quote.QuoteNo-img" src="~/Images/plus.png" /> @quote.First().Quote.QuoteNo @quote.First().Quote.Date</div>
<div class="quote" id="@quote.First().Quote.QuoteNo-quote">
感谢您的帮助
答案 0 :(得分:1)
<script>
$(document).ready(function () {
$("#@quote.First().Quote.QuoteNo-title").click(function () {
var img = "#@quote.First().Quote.QuoteNo-img";
if ($(img).attr("src") == "~/Images/minus.png") {
$(img).removeAttr().attr("src", "~/Images/plus.png");
} else {
$(img).removeAttr().attr("src", "~/Images/minus.png");
}
});
});
</script>