开发者

removing HTML tags and inseting space after tag?

<div><p><input type="radio" name="choice"><span>text1</span></p>
<p><input type="radio" name="choice"><span>text2</span></p>
<p><input type="radio" name="choice"><span>text3</span></p>
<p><input type="radio" name="choice"><span>text4</span></p>

</div>

i wan开发者_如何转开发t to remove the html tags , also i need to get all the data in new line, i can get the data using following code, but how i insert line between them ?

code for getting text without tags in a single line ?

function getInfo(Description) {
  return Description.replace(/(<([^>]+)>)/ig,"");
}

i want output like

text1
text2
text3


@kiran: Perhaps something like --

<script type="text/javascript">
    function getInfo(Description) {
        var tmp = Description.replace(/(<([^>]+)>)/ig,"");
        return tmp.replace(/\n/g, "<br>")
    }
    var somevar;
    somevar  = "<div><p><input type=\"radio\" name=\"choice\"><span>text1</span></p>\n";
    somevar += "<p><input type=\"radio\" name=\"choice\"><span>text2</span></p>\n";
    somevar += "<p><input type=\"radio\" name=\"choice\"><span>text3</span></p>\n";
    somevar += "<p><input type=\"radio\" name=\"choice\"><span>text4</span></p>\n";

    document.write(getInfo(somevar));
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜