question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Appending styled text

See original GitHub issue

Informations

what i need to do is to append html elements and text such as :

var bold = document.createElement("b");
var italic = document.createElement("i");
var underline = document.createElement("u");
var text= document.createTextNode("hi");
 italic.appendChild(bold);
 bold.appendChild(text);
 underline.appendChild(italic); 

now i have to insert it into editor.

I am making smth for transcribing, so this would be used on key cmd to insert some kind of text.

for inserting regular text, without style, I used this function

// adds  Speaker's id into the editor
function addSpeaker(savedID){ 
  if(savedID==null){
    return;
  } else{
    var x = document.execCommand('insertHTML', false, savedID);
    console.log(byId('editor'));
    console.log(x);
  }
}

I tried

// Set HTML content
trumbowyg.html('<p>Your content here</p>');

all the possibilities, but none of them works.

help?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
karovskacommented, Mar 22, 2018

regardless your utterly sarcastic attitude, thank you for your absolutely useless comment which does not at all responds to my question. I want to append elements in html, not insert in it.

1reaction
Alex-Dcommented, Mar 22, 2018

Keep cool. I anwser to many issues each days on my free time. You are unclear. So I did not understand your point.

Without sarcasm:

  • What did you have in the editor at the start?
  • How did you want allow user to trigger this operation
  • What the expected result in the editor HTML?

I want to help you but Idk how since I do not get your need.

Note: please, next time, use markdown to color your code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using .append() + css/styling to add new text using Jquery ...
You can't add style to text, you need to create a new element, either a DIV or a SPAN, and put the style...
Read more >
How to style some appended text on page - Sololearn
pls how do i style appended stuffs on a page using javascript i tried using (classList and the .style method but its not...
Read more >
How to Append or Add text to a DIV element using JavaScript
I have shared two examples here explaining how to add or append text to a div element dynamically using javascript.
Read more >
Styled Text Field - the Draftbit Docs!
The Styled Text Field is a single line and gives you the ability to add labels for each Text Field. Adding Styled Text...
Read more >
Appending Style Nodes with Javascript | Jon Raasch's Blog
Here we created a style node in the DOM and added type="text/css" . If you need to attach a media attribute, simply add:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found