我有一个 Javascript 变量。变量如下所示
var str = '< table class = "buy_selection" >
< tbody >
< tr >
< th > size < / th >
< td >
< select id = "Specification_select" name = "Specification" >
< option value = "014 black / white" > 014 black / white < / option >
< option value = "100 white/v red" > 100/v red white < / option >
< option value = "101 white/black" > 101 white/black < / option >
< option value = "102 white/white" > 102/white < / option >
< / select >
< / Td >
< / tr >
< tr >
< th > color < / th >
< td >
< select id = "Specification_select" name = "Specification" >
< option value = "23.0" > 23.0 < / option >
< option value = "23.5" > 23.5 < / option >
< option value = "24.0" > 24.0 < / option > 24.5
< option value = "24.5" > < / option >
< option value = "25.0" > 25.0 < / option >
< option value = "25.5" > 25.5 < / option >
< option value = "26.0" > 26.0 < / option >
< option value = "26.5" > 26. 5 < / option >
< option value = "27.0" > 27.0 < / option >
< option value = "27.5" > 27.5 < / option >
< option value = "28.0" > 28.0 < / option >
< option value = "28.5" > 28.5 < / option >
< option value = "29.0" > 29.0 < / option >
< option value = "30.0" > 30.0 < / option >
< option value = "30.5" > 30.5 < / option >
< option value = "31.0" > 31.0 < / option >
< / select >
< / td >
< / tr > write < tr >
< th > reviews 10 0 Yen discount < / th >
< td >
< select id = "Specification_select" name = "Specification" >,
< option value = "review to write" > write reviews < / option >
< option value = "write a review [100-yen discount]" > [100-yen discount] write a review < / option >
< / select >
< / td >
< / tr >
< / tbody > ';
我需要格式化这张表并使用 Javascript 或 jQuery 分配到一个 div 中。
我已经尝试过trim()
and html_entity_decode
,但它没有删除任何不需要的空格。
< table class = "buy_selection" >
我如何格式化变量。请指教。