在span文本之后添加文本不在span标记内

时间:2017-09-06 07:41:53

标签: javascript jquery html css

查看此屏幕截图:

enter image description here

我正在使用此代码在DIV中添加表情符号的范围。

$('body').on('click', '.selectable-icons', function(e) {
    if (e.target.tagName.toLowerCase() === 'span') {
        document.querySelector('[contenteditable]').appendChild(e.target.cloneNode(true));
        $('[contenteditable]').append(" ");
        var current_text = $('[contenteditable]').html();
        alert(current_text);
        $('.publisher_div').html(current_text);
    }

但是span标记之后没有附加空格,因此我可以在span标记之后写下一个文字。

3 个答案:

答案 0 :(得分:3)

par(bg="white") Y10= scatterplot3d(WF$`YEAR 1`, WF$ST, WF$D1, grid=TRUE, xlim=c(1,10),ylim=c(0,120),type = "h", pch=".", bg="black" ,xlab="YEAR", ylab="Sales Turnover", zlab="Distribution", color="#80FFFFFF", main = "Corp Behavior, Sales Turnover", angle=55) Y10$points3d(WF$`YEAR 2`, WF$ST, WF$D2 , col="#99FFFFFF", type = "h", pch=".") Y10$points3d(WF$`YEAR 3`, WF$ST, WF$D3 , col="#B3FFFFFF",type = "h", pch=".") Y10$points3d(WF$`YEAR 4`, WF$ST, WF$D4 , col="#CCFFFFFF",type = "h", pch=".") Y10$points3d(WF$`YEAR 5`, WF$ST, WF$D5 , col="#E6FFFFFF",type = "h", pch=".") Y10$points3d(WF$`YEAR 6`, WF$ST, WF$D6 , col="#FFE6FFFF",type = "h", pch=".") Y10$points3d(WF$`YEAR 7`, WF$ST, WF$D7 , col="#FFCCFFFF",type = "h", pch=".") Y10$points3d(WF$`YEAR 8`, WF$ST, WF$D8 , col="#FFB3FFFF",type = "h", pch=".") Y10$points3d(WF$`YEAR 9`, WF$ST, WF$D9 , col="#FF99FFFF",type = "h", pch=".") Y10$points3d(WF$`YEAR 10`, WF$ST, WF$D10 , col="#FF80FFFF",type = "h", pch=".") 会为具有$('[contenteditable]').append(" ");属性的元素添加空格(在您的情况下为contenteditable)。如果您想在之后添加空格,请使用http://api.jquery.com/after/

span

直播示例:

$('[contenteditable]').after(" ");
var container = $("#container");
console.log("Before:");
container.contents().each(function(index) {
    console.log(index, this.nodeType, this.nodeType === 3 ? '"' + this.nodeValue + '"' : this.tagName);
});
$('[contenteditable]').after(" ");
console.log("After:");
container.contents().each(function(index) {
    console.log(index, this.nodeType, this.nodeType === 3 ? '"' + this.nodeValue + '"' : this.tagName);
});

答案 1 :(得分:0)

试试这个

  $('.publisher_div').append("hi");

答案 2 :(得分:-1)

尝试:

path = "/home/user/test.csv"
datalist = []
with open(path, "rb") as fp:
    for row in fp.readlines():
        tmp = row.split(",")
        try:
            datalist.append((float(tmp[0]), float(tmp[1]), float(tmp[2]), float(tmp[3])))
        except:pass

mdb.models['Model-1'].MappedField(name='AnalyticalField-1', description='', 
        regionType=POINT, partLevelData=False, localCsys=None, 
        pointDataFormat=XYZ, fieldDataType=SCALAR, xyzPointData=datalist)