Edit in JSFiddle

// control
var registerButton = document.getElementById('registerButton');
registerButton.addEventListener("click", function () {
  if (ua.isRegistered())
      ua.unregister();
  else
      ua.register();
}, false);

var state = document.getElementById('state');

// minimal user agent
var ua = new JsSIP.UA({
    'ws_servers': 'wss://tryit.areteasea.com:8081',
    'uri': 'sip:demonstration@iptel.org',
    'password': 'd3m0nstr4t10n',
    'register': false
});

// ua event handlers
ua.on('registered', function(){
    state.value = 'Yes';
    registerButton.value = 'Unregister';
});

ua.on('unregistered', function(){
    state.value = 'No';
    registerButton.value = 'Register';
});
ua.start();
is Registered:
<input id="state" type="text" value="No">
<input id="registerButton" type="button" value="Register">

<!-- Open the browser's JavaScript console to see the logs  -->
<script>JsSIP.debug.enable("*");</script>

<!-- jssip.js is included by JsFiddle as External Resources -->