JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<input type="text" id="url">
<br/>
<input type="button" value="Get Top Domain" id="getTopDomain"/>
JavaScript
jQuery('#getTopDomain').click(function() {
var regex = new RegExp(/\./g)
var text = jQuery('#url').val();
var count = text.match(regex).length;
if(count > 1) {
text = text.substring(text.indexOf('.')+1);
}
alert(text);
});