To get a Boolean with jQuery...
var startpageentry = !! $('#' + startpageid).length;
Without jQuery...
var startpageentry = !! document.getElementById(startpageid);
Of course, you don't really need a Boolean to test it. You could just rely on 0
being falsey (for the jQuery version) or null
being falsey (for the non jQuery version).
Also, your but that doesn't return anything isn't correct. It would return a reference to the jQuery object returned. Objects in JavaScript are always truthy, so testing it in a condition won't tell you if the selector matched any elements or not.