Javascript 使用jquery删除最后一个
我可以用jQuery添加一个手风琴。但现在我还想删除最后选定的手风琴。我是这样的: HTML: 但这不起作用 这是html:Javascript 使用jquery删除最后一个,javascript,jquery,html,Javascript,Jquery,Html,我可以用jQuery添加一个手风琴。但现在我还想删除最后选定的手风琴。我是这样的: HTML: 但这不起作用 这是html: <div class="span12" id="add-contact"> <p style="text-align: center;"> <a href="#">Klik hier om nog een contactpersoon toe te voegen</a>
<div class="span12" id="add-contact">
<p style="text-align: center;">
<a href="#">Klik hier om nog een contactpersoon toe te voegen</a>
</p>
</div>
<div class="span12" id="delete-contact">
<p style="text-align: center;">
<a href="#">Klik hier om contactpersoon te verwijderen</a>
</p>
</div>
如果我这样做:
$('#delete-contact p a').click(function(event)
{
event.preventDefault();
//$(this).parents('.panel').eq(0).remove();
// $("#accordion).accordion("destroy"); // Removes the accordion bits
$("#accordion").empty();
});
然后所有的手风琴手都会被删除。例如,我有两个手风琴手,最后的一个-两个必须删除。但现在两者都将被删除
我试着这样做:
$('#delete-contact p a').click(function(event)
{
event.preventDefault();
//$(this).parents('.panel').eq(0).remove();
// $("#accordion).accordion("destroy"); // Removes the accordion bits
$("#accordion").empty({ active: index });
但现在两本手风琴都不会被删除
});
有关链接单击时的页面重定向问题,请尝试以下操作:
<a href="#">Klik hier om nog een contactpersoon toe te voegen</a>
将href属性替换为“javascript:void(0)”,这将阻止页面加载
例如:
<a href="javascript:void(0);">Klik hier om nog een contactpersoon toe te voegen</a>
有关链接单击时的页面重定向问题,请尝试以下操作:
<a href="#">Klik hier om nog een contactpersoon toe te voegen</a>
将href属性替换为“javascript:void(0)”,这将阻止页面加载
例如:
<a href="javascript:void(0);">Klik hier om nog een contactpersoon toe te voegen</a>
get(0)
获取本机DOM节点,在一些现代浏览器中,本机DOM节点会有一个remove()
方法,但您可能需要jQuery对象,为此您会使用eq(0)
。因此我更改了它。下一步是什么???get(0)
获取本机DOM节点,在一些现代浏览器中会有一个remove()
方法,但您可能需要jQuery对象,为此您将使用eq(0)
。因此我更改了它。下一步是什么?谢谢。但我解决了这个问题。我在帖子里更新了谢谢。但我解决了这个问题。我在帖子里做了更新
<a href="javascript:void(0);">Klik hier om nog een contactpersoon toe te voegen</a>