【发布时间】:2017-02-27 22:46:22
【问题描述】:
我正在编写 ASP.NET 应用程序
我有一个 div,这里是代码:
<div class="title" style="margin-top:15px;margin-left:15px;">
<img class="click" src="@Url.Content(" ~/Images/plus_plus.png")" />
<span>
@Html.TextBoxFor(modelItem => item.question, new {@class="testclass", @readonly = "readonly" })
</span>
<a class="click2" style="margin-left:10px;">
<img src='@Url.Content("~/Images/arrow.png")' />
</a>
<a style="margin-left:25px;" href='@Url.Action("Edit", "Questions", new {id = item.QuestionId})'>
<img src='@Url.Content("~/Images/Edit.png")' />
</a>
<a href='@Url.Action("Delete", "Questions", new {id = item.QuestionId})'>
<img src='@Url.Content("~/Images/Delete.png")' />
</a>
</div>
我需要把它移到另一个。这是代码:
<div class="title2"></div>
据我了解,需要通过 jquery 来完成。
我试着写这个脚本
<script type="text/javascript" >
$('.title').on('click', function () {
$(this).next().toggle();
});
$('click2').click(function () {
var elem = $(this).closest('.title');
elem.hide();
$('title2').append(elem).show();
elem.remove();
});
</script>
但它不起作用。我的问题在哪里?
【问题讨论】:
-
$('title2').append(elem).show();上面的所有内容都工作了吗?还是只是那条线? -
不,elem 没有隐藏@BviLLe_Kid
-
您在
$('click2')和$('title2')中缺少.,它必须是$('.click2') -
好的,现在块被隐藏了,但没有显示在另一个 div@CarstenLøvboAndersen
-
可能是这一行正在从你的 DOM 中删除标题 div:elem.remove();
标签: c# jquery html asp.net asp.net-mvc