I'm trying to swap two HTML paragraphs with a JavaScript button. The code seems to all check out, so I can't seem to figure out why it's not working!
HTML:
<p id="p1"> Donald Drumpf paced and loomed behind Hillary Clinton at times during Sunday night's second presidential debate -- a decision possibly driven by stress during the intensely bitter event, according to body language expert Janine Driver. </p>
<p id="p2"> "He's decreasing stress by doing all that movement," Driver said of Drumpf's behavior on CNN's "New Day" on Monday. </p>
<button onclick="swapT()"> Swap </button>
JS:
function swapT()
{
var obj1 = document.getElementById('p1');
var obj2 = document.getElementById('p2');
var temp = obj1.innerHTML;
obj1.innerHTML = obj2.innerHTML;
obj2.innerHTML = temp;
}
I get the error:
Uncaught ReferenceError: swapT is not defined
What's going wrong?