I've been told that getting elements by getElementbyid or jQuery("#tagname") is considered a "hack".

The argument is that is not compiled, and therefore could take a long time to track down a silly typo.

Or a better argument: it would take a long time to refactor everything when a certain element id changes.

What are some arguments against this "hack" argument?
And is there a nice solution around it?