Answers for "javascript get content between tags"

0

javascript get content between tags

var str = "<b>Bob</b>, I'm <b>20</b> years old, I like <b>programming</b>.";

var result = str.match(/<b>(.*?)<\/b>/g).map(function(val){
   return val.replace(/<\/?b>/g,'');
});
//result -> ["Bob", "20", "programming"]
Posted by: Guest on July-07-2020
0

get contents between tags javascript

// Using ES2015+ fat-arrow-function syntax
const getTextOfElement = () => {
  const element = document.getElementById('elementId'); // Get desired HTML element
  console.log(element.textContent); // Get text of element & display in console 
}
Posted by: Guest on May-20-2020

Code answers related to "javascript get content between tags"

Code answers related to "Javascript"

Browse Popular Code Answers by Language