我有我的内容可编辑 div:
div {
width: 200px;
height: 300px;
border: 1px solid black;
}Run Code Online (Sandbox Code Playgroud)
<div contenteditable="true" spellcheck="false" style="font-family: Arial;">
<b>Lorem ipsum</b> dolor sit amet, <u>consectetur adipiscing elit.
Morbi sagittis</u> <s>mauris porta arcu auctor, vel aliquam ligula ornare.</s>
Sed at <span id="someId">semper neque, et dapibus metus.
Maecenas dignissim est non nunc feugiat</span>
sollicitudin. Morbi consequat euismod consectetur. Mauris orci
risus, <b>porta quis erat ac, malesuada</b> fringilla odio.
</div>
<button>Get current line HTML</button>Run Code Online (Sandbox Code Playgroud)
我想创建一个按钮,从当前行给我HTML代码.例如:
当我的插入符号位于第二行时,我想得到:
amet, <u>consectetur</u>
Run Code Online (Sandbox Code Playgroud)
或在第七行:
<span id="someId">dapibus metus. …Run Code Online (Sandbox Code Playgroud) 我有contentEditable div,每个字母都有自己的元素,如:
<div contenteditable="true">
<p id="p1">
<span id="s1">S</span>
<span id="s2">o</span>
<span id="s3">m</span>
<span id="s4">e</span>
<span id="s5"> </span>
<span id="s6">t</span>
<span id="s7">e</span>
<span id="s8">x</span>
<span id="s9">t</span>
</p>
</div>
Run Code Online (Sandbox Code Playgroud)
我试图证明使用更长的文本text-align: justify,但这不起作用.这很奇怪,因为text-align: center而且text-align: right有效.
之后,我试图使用添加margin-right到每个空间的脚本来做到这一点,但是当我将新文本写入段落时,它会崩溃.
如何id使用JavaScript和/或JQuery 执行此操作(以及在每个元素中保存和其他属性)?
我正在编写一个脚本来将元素的内容复制到父元素,并删除该元素.元素和父元素具有相同的类.例如:
在脚本运行之前:
<span class='SomeClass'>
Some
<span class='SomeClass'>
Copied
</span>
Text
</span>
Run Code Online (Sandbox Code Playgroud)
后:
<span class='SomeClass'>
SomeCopiedText
</span>
Run Code Online (Sandbox Code Playgroud)
以下是我的代码.内部元素的文本("复制")最终在行尾,而不是"某些"和"文本"之间.我该如何解决?
if ($('.SomeClass > .SomeClass').length > 0) {
$('.SomeClass > .SomeClass').each(function(index, event) {
$(this).parent().append($(this).html());
$(this).remove();
});
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="SomeClass">
Some
<span class="SomeClass">
Copied
</span>
Text
</span>Run Code Online (Sandbox Code Playgroud)
我有span与::after伪元素:
#someId {
font-family: Arial;
font-size: 36px;
color: red;
}
#someId::after {
content: 'B';
}Run Code Online (Sandbox Code Playgroud)
<span id="someId">A</span>Run Code Online (Sandbox Code Playgroud)
我想让::after元素可见,同时隐藏主要元素。我尝试使用opacityandfilter: opacity和visibility,但这没有用。如何在不操作color属性的情况下实现所需的行为,同时保持文本可选?
谢谢你的帮助。
red wavy underline我想用和blue dashed overlineusing来制作文本text-decoration。
这是我的代码:(仅在 Mozilla Firefox 中工作)(不起作用,因为仅显示上划线)
span {
font-size: 40px;
text-decoration: underline wavy red;
text-decoration: overline dashed blue;
}Run Code Online (Sandbox Code Playgroud)
<span> Some Text </span>Run Code Online (Sandbox Code Playgroud)
text-decoration?(我知道,它只能在 Mozilla Firefox 中运行)我有一个问题.我想为像Orange Pi Zero Plus 2这样的小型机购买GSM/GPS/3G模块,所以它不能像Raspberry Pi GSM Hat那样.我发现了非常好的模块,但我不确定某些事情.也许你可以帮助我.
第一.网络连接.SIM5320是3G模块,因此最大互联网连接速度为3.6Mb.如下图所示,该模块只有UART接口.我能通过UART接口使用最高3G速度吗?
第二.音频.该模块没有音频输入或输出.那么我可以使用UART接口和AT命令发送和接收音频吗?
预先感谢您的帮助.
我对div内容满意:
<span style="font-weight: 700">S</span>
<span style="font-weight: 100">o</span>
<span style="color: red">m</span>
<span style="text-decoration: underline">e</span>
<span style="background-color: green">T</span>
<span style="text-decoration: line-through">e</span>
<span style="font-style: italic">x</span>
<span style="font-family: Arial">t</span>
Run Code Online (Sandbox Code Playgroud)
而且我想获得插入符号(光标)之前的元素的样式.例如,如果我之间有插入Some,Text我想得到text-decoration: underline.我的代码在下面(工作,但我得到了最后一个元素(font-family: Arial)的样式).如何使用JavaScript或/和JQuery修复它?
感谢帮助.
$('button').click(function() {
var style = $('#Box span').last().attr('style');
$('#Result').text('Result: ' + style);
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="Box" contenteditable="true">
<span style="font-weight: 700">S</span><span style="font-weight: 100">o</span><span style="color: red">m</span><span style="text-decoration: underline">e</span><span style="background-color: green">T</span><span style="text-decoration: line-through">e</span><span style="font-style: italic">x</span><span style="font-family: Arial">t</span>
</div>
<button>Get result</button>
<p id="Result"></p>Run Code Online (Sandbox Code Playgroud)
我想只 得到一条<span>有三条线(下划线,删除线和上线),这样:(这只是一个例子,我想动态地改变它)

但是我不能text-decorations在这样的一个元素中使用很少的东西:
span {
text-decoration: overline dotted green;
text-decoration: line-through wavy aqua;
text-decoration: underline double red;
}
Run Code Online (Sandbox Code Playgroud)
我怎么能用一个<span>呢?也许我可以使用::after和::before其他语言,如SASS或LESS?
感谢帮助.
我有这样的情况:
<div>
<span id="x1"></span>
<span id="x2"></span>
<span id="x3"></span>
</div>
Run Code Online (Sandbox Code Playgroud)
而我正试图得到这样的东西:
<div>
<span id="x1"></span>
</div>
<span id="x2"></span>
<div>
<span id="x3"></span>
</div>
Run Code Online (Sandbox Code Playgroud)
我尝试使用这样的unwrap()函数来做到这一点:
$('#x2').unwrap();
Run Code Online (Sandbox Code Playgroud)
但是这个功能删除了整个<div>.那我怎么能用jQuery/JavaScript呢?感谢帮助.