English 中文(简体)
在要素之前删除内容和内容
原标题:Remove the elements and contents before an element
  • 时间:2010-06-01 00:16:31
  •  标签:
  • jquery
  • forms

I am trying to remove the elements and contents before a link inside a div when a user clicks a button. What is the best way to do it??

<div id="dialog" class="window">  

         //will be inserted a <select> element and few text here 
         //but I want to clear them after the user click a button

    <a href="#" class="close">Close it</a>  // I want to keep this <a> link.    

    </div>  

My Jquery

$( .model ).click(function(e) {  

   $("#dialog").empty();  //I can t use this because <a> will be deleted. Any better ideas?         

});

感谢答复......

最佳回答

简单地把所有这些因素一分为二,予以删除。

$( #select-wrapper ).remove();

或者说,这更是朋友

$( #select-wrapper ).fadeOut(500, function() { $(this).remove(); });
问题回答

试图把你想要删除的内容放在自己的部分。 然后,在点击事件上隐藏/移走干.会很简单。

您是否真的希望保持<条码>a的链接,或者你是否只是希望这四条能够包含一个与以后一样的链接?

为什么不光超高超地使用<a href=“#”等;Close it</a>?

我的理解是,如果这一联系在某种程度上超出了你们的知识或控制范围,那么你就必须保持这一联系,但除非情况如此,否则,光顾就会照亮。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签