0
Q:

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"] 
0
// 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 
}
0

New to Communities?

Join the community