get an html img tag from a string
var div = document.createElement('div');
div.innerHTML = post_body;
var firstImage = div.getElementsByTagName('img')[0]
var imgSrc = firstImage ? firstImage.src : "";
// or, if you want the unresolved src, as it appears in the original HTML:
var rawImgSrc = firstImage ? firstImage.getAttribute("src") : "";
Also in JavaScript:
- express limit based on ip
- react native elements
- navigation in react native
- javascript leave page warning
- set ibm cloud node environment variables
- responsive grid using antd
- data at transit encrypting nodejs stack overflow
- js getattribute
- how to make a array in javascript
- react native flexbox 2 columns 1 fixed width
- vue deep watch
- js remove first and last element from array
- how to get file extension in javascript last index
- electron send message from renderer to main
- check array values equal js
- unexpected token react native stack navigation
- javascript get file extension from string
- use bootstrap in react
- Setting axios base url dynamically
- Module not found: Can't resolve '@date-io/date-fns' in 'C:\Users\61455\Documents\React apps\mya2o\src\pages'
- ternaire javascript
- this.setstate is not a function in react native
- how to get mouse coordinates in javascript
- self invoking function javascript es6