Skip to content

Tag: split

How to get textContent including childNodes?

I have some plain text content in paragraphs inside a <main> HTML element. the paragraphs are separated by new lines (n), not in <p> tags, and I would like to automatically wrap them in <p> tags using JavaScript. Example content: Inside of <main> there may be <img> elements. I wa…

Split URL that contains more than one comma javascript

Basically I try to split a string of URL that contains more than one Comma, but the result turns out to be like this: Here is my code, is there a way to fix it…. URL Before splitted: Answer Since we know the url starts with https:// we can check each segment for it and build up url accordingly:

how to split a string with anything that is not a number

string input: “12 apples, 3 oranges, 10 grapes” solution: let arr= inputString.split(” “); issue to solve: how would I go about splitting with anything that isn’t a number? string examples: no spaces 12apples,3oranges,10grapes numbers that are inside () there are some (12) digits…

Split String and insert it in different input

can you please help me how to split a string in an input and insert those split strings into different inputs? I already tried some codes that I found here but it still didn’t work. I actually want to store the string in that 2 different inputs (those not hidden) after exectuting the functions This is t…