That's not javascript, but jQuery:
You can simply use hide() method:
$(".ui-dialog-titlebar-close").hide(); // you can also use css() method as yours
And you need to wrap your code inside ready handler:
$(document).ready(function(){
//your code here
});
You can learn more about jQuery here.