Sunday, 15 July 2012

javascript - Unable to remove html content using JQUERY -



javascript - Unable to remove html content using JQUERY -

i unable remove div id "third" , display result content in div id "fourth". please note :- need append #third content #fourth , remove @ later stage.

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="../jquery-ui-1.10.4.custom/js/jquery-1.10.2.js" type="text/javascript"></script> <script src="../jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js" type="text/javascript"></script> <link href="../jquery-ui-1.10.4.custom/css/ui-lightness/jquery-ui-1.10.4.custom.min.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $(function() { var widget = {} $("#vshowdialog").click(function() { widget.doinitialize(); }); widget.doinitialize = function() { $("#fourth").append($("#first").html()); $("#fourth").append($("#second").html()); $("#fourth").append($("#third").html()); widget.showlightbox(); }; widget.showlightbox = function() { text = $('#fourth').html(); $(text).find("#third").remove(); $("#fourth").dialog(); }; }); </script> </head> <body> <input type="button" id="vshowdialog" value="showdialog" /> <div id="first"> <div id="content"> main firstcontent.</div> <div id="sidebar"> firstsidebar</div> </div> <div id="second"> <div id="secondone"> main sec content.</div> <div id="secondtwo"> sec sidebar</div> </div> <div id="third"> hello <div id="thirdone"> main 3rd content.</div> <div id="thirdtwo"> 3rd sidebar</div> </div> <div id="fourth"> </div> </body> </html>

you can use:

$('#fourth').append($('#third')); $('#thirdone').unwrap();

working demo

or

$('#fourth').append($('#third')).find('#thirdone').unwrap();

working demo

javascript jquery html

No comments:

Post a Comment