Instead your both functions use toggle
function with following body
this[target].parentNode.style.display = 'none'
this[source].parentNode.style.display = 'block'
function toggle(target, source) {
this[target].parentNode.style.display = 'none'
this[source].parentNode.style.display = 'block'
}
_x000D_
<button onClick="toggle('target', 'replace_target')">View Portfolio</button>
<button onClick="toggle('replace_target', 'target')">View Results</button>
<div>
<span id="target">div1</span>
</div>
<div style="display:none">
<span id="replace_target">div2</span>
</div>
_x000D_