Strip HTML from Text JavaScript

前端 未结 30 4098
北荒
北荒 2020-11-21 05:08

Is there an easy way to take a string of html in JavaScript and strip out the html?

30条回答
  •  南旧
    南旧 (楼主)
    2020-11-21 05:36

    simple 2 line jquery to strip the html.

     var content = "

    checking the html source 

     

    with 

    all

    the html 

    content

    "; var text = $(content).text();//It gets you the plain text console.log(text);//check the data in your console cj("#text_area_id").val(text);//set your content to text area using text_area_id

提交回复
热议问题