Sharepoint - Hide/disable ribbon bar buttons with client-side code
here the answer:
<script type="text/javascript">
function hideEdit() {
var edit = document.getElementById("Ribbon.ListForm.Display.Manage.EditItem-Large");
edit.style.display = "none";
}
_spBodyOnLoadFunctionNames.push("hideEdit");
</script>
Or
Enable/Disable ribbon button based on current item value of a field
I was able to do this using pure CSS, but had to escape the "." As follows:
<style type="text/css">
#Ribbon\.ListForm\.Display\.Manage\.EditItem-Large {display:none !important;}
</style>
Did you mean EditForm.aspx? Cause for Doc libaries there's no NewForm.aspx
To hide it using CSS:
#Ribbon a[id$="Cancel-Large"] {
display: none !important;
}
To hide it using jQuery:
$("#Ribbon a[id$='Cancel-Large']").hide();
I would suggest using a combination of both and use remove() instead of hide(). You could add the jQuery script using JSLink or Script editor.