freedomn-m's comment is correct: you're better off setting a click handler using JavaScript. I'd do it more like this:
function ShowButtons() {
let $button = $("<button></button>");
$button.click(() => CheckID("MYID"));
$("#ServicesPreview").empty().append($button);
}
You'll find this pattern gives you a lot more flexibility to componentize your code in the long run. It's better to avoid relying on HTML IDs since they have to be unique across the DOM, so they're kind of like global variables.
But if you have to stick with the pattern you're asking about, the way to address quotes in quotes is to escape the quotes for the context that they're in. Since your quotes are inside HTML, you can use HTML escaping:
function ShowButtons() {
let $previewDiv = $("#ServicesPreview");
$previewDiv.html("<button id='myBtn' onclick='CheckID("MYID")'></button>")
}
Or, since you're in JavaScript, you could escape the JavaScript double-quotes.
function ShowButtons() {
let $previewDiv = $("#ServicesPreview");
$previewDiv.html("<button id='myBtn' onclick='CheckID(\"MYID\")'></button>")
}
Or you could use back-ticks in the first place so the double-quotes don't need escaping.
function ShowButtons() {
let $previewDiv = $("#ServicesPreview");
$previewDiv.html(`<button id='myBtn' onclick='CheckID("MYID")'></button>`)
}