Я получил элемент HTML, содержащий это:
<!--Product Style--> <div style="float: right; padding-top: 4px; padding-bottom: 5px;"> P6C245RO </div> <div style="text-transform: uppercase; font-weight: bold; padding-top: 4px; padding-bottom: 5px;"> Style </div> <div style="clear: both; border-top: 1px solid rgb(216, 216, 216); padding-top: 4px;"> <!--Product Description--> <div style="font-size: 11px ! important;"></div> <div style="background: url("http://ii.armaniexchange.com/ArmaniExchange/images/en_US/global/globalgraphics/bullet.gif") no-repeat scroll 0pt 4px transparent; padding-left: 12px;">fine tonal striped fabric</div> <div style="background: url("http://ii.armaniexchange.com/ArmaniExchange/images/en_US/global/globalgraphics/bullet.gif") no-repeat scroll 0pt 4px transparent; padding-left: 12px;">epaulettes and sleeve tab</div> <div style="background: url("http://ii.armaniexchange.com/ArmaniExchange/images/en_US/global/globalgraphics/bullet.gif") no-repeat scroll 0pt 4px transparent; padding-left: 12px;">metal logo plate on the chest pocket</div>
Когда я читаю его с помощью jquery, я получаю, что .text()
содержит много пробелов и /n между текстом, но без тегов html.
Как удалить все эти пробелы и вернуть чистый текст с помощью jquery или чистого javascript?