Click here to Skip to main content
15,896,376 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here is my code. modifeidCCDHTML is my HTML string. I tried to remove some paragraphs from a division $sectionDiv. After removing the paragraphs i have checked for the html content of $sectionDiv. paragraphs got removed. But paragraphs are still appearing in the HTML string modifiedCCDHTML.Please help me where I have done the mistake?

C#
var modifiedCCDHTML = CLINICAL_SUMMARY_O1.xmlToHTML()
    $(modifiedCCDHTML).find("span").each(function () {
         var templateId = $(this).attr("ID");
            if ($.inArray(templateId, identifiers.Instructions) > -1) {
                var $sectionDiv = $(this).parent("div");

                if (flagForTitle === "SCRIPT.XR_CUST_DISCH_INFO") {
                    $sectionDiv.find("p").each(function () {
                        if ($(this).find("span").attr("class") === "Bold") {
                        }
                        else {
                                $(this).hide();
                        }
                    });
                }
                    var modInstHTML = $sectionDiv.html();
            }
    });
Posted
Comments
Sergey Alexandrovich Kryukov 8-Jan-15 2:40am    
Where?!
—SA

1 solution

In your code, you never use .remove() (no .detach(), .empty(), .unwrap() :-)). Please read on removal: http://api.jquery.com/category/manipulation/dom-removal[^].

It works. If you actually done it somewhere else, do it thoroughly, check up with the debugger, and so on.

—SA
 
Share this answer
 
Comments
Harika Thadepalli 8-Jan-15 3:36am    
I have tried .hide() instead of .remove().Still issue persists. In the HTML page I am able to see all the paragraphs. Thanks for the reply.
Sergey Alexandrovich Kryukov 8-Jan-15 11:31am    
"Hide" does not remove anything. You need to remove. Did you do it?
Even with hiding, did you do it under the debugger, to see what is hidden? What is "this", in this case?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900