i have a div tag named

<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 div1.
as like 0,2,3,

how can i remove content from div tag.

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];  
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.