Edit in JSFiddle

var att = document.getElementById("att");
var output = document.getElementById("output");

function setAtt() {
  att.setAttribute('class', 'myClass');
  output.innerHTML = "class=\"myClass\" 설정";
}

function getAtt() {
  if (att.hasAttribute('class')) { // class 속성이 있는지 확인
    var val = att.getAttribute("class");
    output.innerHTML = "요소의 class 속성의 값은 : " + val;
  } else {
    output.innerHTML = "요소에 class 속성이 없습니다.";
  }
}

function removeAtt() {
  att.removeAttribute("class");
  output.innerHTML = "class=\"myClass\" 제거";
}
<button type="button" onclick="setAtt()">속성설정 : setAttribute()</button>
<button type="button" onclick="getAtt()">속성읽기 : getAttribute()</button>
<button type="button" onclick="removeAtt()">속성제거 : removeAttribute()</button>
<p id="att">Hello World!</p>
<p id="output"></p>
.myClass {
  font-size: 2em;
  font-weight: bold;
  color: orange;
}