0

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.

1
Contributor
1
Reply
3
Views
7 Years
Discussion Span
Last Post by MARKAND911
0

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];  
  }
}

Edited by __avd: Added [code] tags.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.