Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a div tag like this:
XML
<div id="div1" runat="server"></div>

I wrote a Javascript which adds content like 0,1,2,3, in this div tag as its content.
Now I want a script which will delete some of the content of this div for ex 0,2,3.
How can I remove content from div tag.
Posted
Updated 23-Sep-10 1:01am
v3

JavaScript
document.getElementById('divStatus').innerHTML = "";
 
Share this answer
 
v2
var divStatus = document.getElementById("divStatus");<br />
divStatus.innerText = divStatus.innerText.replace("0,1","");


vote if it helps
 
Share this answer
 
Use

C#
function LoadResponse(response,control)
{
    var container = document.getElementById(control);
    try
    {
        while(container.firstChild)
            container.removeChild(container.firstChild);
        var t = document.createElement('div');
        t.innerHTML = response;
        container.appendChild(t);
    }
    catch(ex)
    {
        container.innerHTML = response;
    }
}


Now call LoadResponse('', divid)

It will remove the content totally.
 
Share this answer
 
I got my answer.

var strSplit = document.getElementById('div1').innerHTML.split(",");
var strOut = "";
for (var i = 0; i < strSplit.length; i++) {
if (strSplit[i] != "1") {
if (strOut == "")
strOut = strSplit[i];
else
strOut = strOut + "," + strSplit[i];
}
}
 
Share this answer
 
Quote:
document.getElementById('div1').innerHTML = "";
 
Share this answer
 
Hello Everyone,

I have the same kind of problem from long time,what i am doing is i am trying to upload some image and loading into the div,after uploading image i need to delete if i want to and upload new image,but i am getting the same image what i uploaded before instead of getting new image.
i used the following code for loading the image.

document.getElemnentById('prod_img').innerHTML=image_path;

when i delete the image i am using following code to clear the old image.

document.getElemnentById('prod_img').innerHTML='';

after uploading new image again i am loading image into prod_img div,but i am not getting what exactly i want.

if anyone can help me to overcome this?????

Thanks in advance.
 
Share this answer
 

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