为什么我不能删除每一行html的空白?
Why can't I remove whitespace of each html line?
我尝试了很多方法,如.trim()或替换,但没有任何工作。https://jsbin.com/biguqe/4/edit?html, js、控制台、输出
这是我的html。我需要点击得到"代码"标签内的内容,就像它是。但是我得到了内容和空白,你可以看到从屏幕边缘到内容。<div class="wrapper">
<code class="copyable">
<dummyTag<br>
id="page"<br>
navButtonPress="onNavBack"<br>
showNavButton="{device>/system/phone}"<br>
title="{i18n>detailTitle}"<br>
busy="{detailView>/busy}"<br>
busyIndicatorDelay="{detailView>/delay}"><br><br>
<dummyTag:positiveAction>
<<dummyTag:PositiveAction id="approveButton" press="onApprove" text="{i18n>xbut.approve}"/><br>
</dummyTag:positiveAction><br>
<dummyTag:negativeAction><br>
<dummyTag:NegativeAction id="rejectButton" press="onReject" text="{i18n>xbut.reject}"/><br>
</dummyTag:negativeAction><br>
<br>
<semantic:content><br>
</code>
<button class="arrangeButton">Arrange</button>
</div>
下面是我的代码:https://jsbin.com/biguqe/4/edit?html,js,console,output
我添加.replace(//g, ")到你的代码,请,看看如果是你想要或不…因为我不懂
$('.arrangeButton').on('click', function() {
console.log($(this).siblings('.copyable').text().replace(/ /g,''));
})
使用此方法将text
更改为html()
,您可以获得完全相同的
$('.arrangeButton').on('click', function() {
console.log($('.copyable').html());
})
相关文章:
- 从 html 表中选择一行(突出显示)并在单击按钮时发送值
- html画布鼠标后的一行
- 当上一行/当前行被填充时,将新行添加到HTML表中
- Html-从数据库中删除一行
- 用 HTML 中的一行连接 2 张图像.姜戈模板
- 如何将动态颜色应用于与 HTML 表不同的每一行
- 从同一行中获取最接近复选框列的列的 html 值
- 使用 JavaScript 编辑 HTML 中的每一行
- 阻止浮动 HTML 元素下降到下一行
- 如何使用jQuery和Ajax将文本文件中的每一行加载到HTML列表中
- JQuery HTML 避免使用每个表中的第一行
- html表的xsl生成为每一行提供一个按钮
- 如何在嵌入php的html表中为每一行添加复选框,并在数据库(Postgresql)中更新其值
- 在不影响第一行的情况下,每隔一行缩进一个表.html/css/js/jQuery
- 如何使用jQuery根据某些条件获取HTML表的下一行
- 阻止一行html出现在谷歌搜索中
- 如何将值获取到一行html数据表中
- 在一个页面被呈现后,任何方式都可以去掉一行HTML代码
- 禁用最后一行html表复选框
- 为什么我不能删除每一行html的空白?