Display Input value on button click

Grab value from input and add both data to display on a button click.

HTML

<input type="text" id="name1" />
<input type="text" id="name2" />
<input type="submit" id="btn1" >
<p id="showName"></p>

JavaScript

$('#btn1').click(function(){
var name1 = $('#name1').val();
var name2 = $('#name2').val();
document.getElementById("showName").innerHTML = name1 - "-" - name2;
});