在innerText中加入一个单词

时间:2018-02-16 02:47:18

标签: javascript html css dom

我想在段落中加注一些单词。到目前为止,我尝试使用HTML标记,然后才意识到它不起作用。有没有办法在没有得到元素的情况下做到这一点?

COL01 =
        structure(list(V1 = c(-0.0431597784900261, -0.518148142834806, 
                              -0.237032580263406, -0.920434206514568, -0.95436194682491, -0.556922703189482
        ), V2 = c(-0.518148142834806, -0.237032580263406, -0.920434206514568, 
                  -0.95436194682491, -0.556922703189482), V3 = c(-0.237032580263406, 
                                                                 -0.920434206514568, -0.95436194682491, -0.556922703189482, -0.988289687135251
                  ), V4 = c(-0.920434206514568, -0.95436194682491, -0.556922703189482, 
                            -0.988289687135251, 0.0569519413796151), V5 = c(-0.95436194682491, 
                                                                            -0.556922703189482, -0.988289687135251, 0.0569519413796151, 0.0981633964482812
                            ), V6 = c(-0.95436194682491, -0.556922703189482, -0.988289687135251, 
                                      0.0569519413796151, 0.0981633964482812, -1.60696055701778)), .Names = c("V1", 
                                                                                                              "V2", "V3", "V4", "V5", "V6"))

COL02 = 
        structure(list(V1 = c(0.490280732997843, -0.232516232554677, 
                              0.237972180098397, -0.988223009354951, -1.33316658650733, -0.603056329566425
        ), V2 = c(-0.232516232554677, 0.237972180098397, -0.988223009354951, 
                  -1.33316658650733, -0.603056329566425), V3 = c(0.237972180098397, 
                                                                 -0.988223009354951, -1.33316658650733, -0.603056329566425, -0.999192946437536
                  ), V4 = c(-0.988223009354951, -1.33316658650733, -0.603056329566425, 
                            -0.999192946437536, 0.00282420705837356), V5 = c(-1.33316658650733, 
                                                                             -0.603056329566425, -0.999192946437536, 0.00282420705837356, 
                                                                             -0.138063379339347), V6 = c(-1.33316658650733, -0.603056329566425, 
                                                                                                         -0.999192946437536, 0.00282420705837356, -0.138063379339347, 
                                                                                                         -1.57598823020269)), .Names = c("V1", "V2", "V3", "V4", "V5", 
                                                                                                                                         "V6"))

col_1 <- unlist(lapply(COL01, paste, collapse=" "))

col_2 <- unlist(lapply(COL02, paste, collapse=" "))

df <- data.frame(col_1, col_2)

str(df)

1 个答案:

答案 0 :(得分:1)

由于字符串中包含一些HTML,并且使用innerHTML而不是innerText来获得效果。

var text2_2 = document.createElement("p");
text2_2.className = "reasoning";
text2_2.innerHTML = "All vitamins are <strong>required</strong> by our ..."

document.body.appendChild(text2_2);