我有一个UI,其中有三个以上的div,其中数据具有不同的ID,但是使用称为“Read”的公共按钮。我已经显示了我将消息体保持为微小的消息(15 )在这个阅读按钮上,它向我显示了整个消息体。如何实现这一点,我想做的是如下:
foreach (var item in Model.MyNote)
{
<div class="row">
@if (item.Owner.Roles.Any(cx => cx.RoleName == "Customer"))
{
<div class="panel">
<div class="row">
<div class="three columns">
<img src="@Request.Url.FormatAbsoluteUrl(@item.Owner.Personal.ImageURL)" />
<span style="text-align: center;">
@item.Owner.Personal.FirstName @item.Owner.Personal.LastName
</span>
</div>
<div class="nine columns">
<input type="hidden" value="@item.Id" id="messid" />
<p class="parahide1">@item.Description </p>
<p class="parahide">@item.Description.ToTiny(15) </p>
</div>
@*<a href="@Url.Action("Read", "Appointment", new { @id = item.Id })" class="button" id="read">Read</a>*@
<button class="button" id="read">Read</button>
</div>
</div>
}
else if (item.Owner.Roles.Any(cx => cx.RoleName == "Professional"))
{
<div class="panel">
<div class="row">
<div class="nine columns">
<p>@item.Description </p>
</div>
<div class="three columns">
<img src="@Request.Url.FormatAbsoluteUrl(@item.Owner.Professional.ImageURL)" />
<span style="text-align: center;">@item.Owner.Professional.CompanyName</span>
</div>
</div>
<a href="@Url.Action("Read", "Appointment", new { @id = item.Id })" class="button">Read</a>
</div>
}
</div>
<script type="text/javascript">
$(function () {
$(".parahide1").hide();
$("#read").live('click',function () {
$(".parahide").hide();
$(".parahide1").show();
});
});
</script>
}
这给出了结果,但它显示了所有div的描述,即使我点击第一个div的按钮。