Home / Admin / Forum
Duplicate Snippet

Embed Snippet on Your Site

Forum

JS code for question and answer page
Sanjay Kumar
<10
Code Preview
js
// create new element
const elem = document.createElement('div')
elem.className = 'quetxt'
// add text
elem.innerText = 'Question:'
elem.style = 'color:#d55900; font-weight:700; font-size: 18px; margin-top:15px; margin-bottom:10px; font-family:Georgia;'
// grab target element reference
const target = document.querySelector('.article-header')
// insert the element before target element
target.parentNode.insertBefore(elem, target.nextSibling)
// create new element
const elem1 = document.createElement('div')
elem1.className = 'anstxt'
// add text
elem1.innerText = 'Solution:'
elem1.style = 'color:#21a300; font-weight:700; font-size: 18px; margin-top:15px; margin-bottom:10px; font-family:Georgia;'
// grab target element reference
const target1 = document.querySelector('.post-wrap-content')
// insert the element before target element
target1.parentNode.insertBefore(elem1, target1)

Comments

Add a Comment