jqeury Attribute
(select).addClass(className)
ex) $("p").addClass("myClass");
(select).removeClass(className)
ex) $("p").removeClasss("ClassName");
(select).attr(attributeName)
(select).attr(attributeName, value)
(select).removeAttr(attributeName)
이 두함수는 선택된 엘리먼트의 속서값을 가져오거나 설정할 수 있도록 합니다.
같은 일을 합니다... 그러니... 클릭하면.. 입력창이 활성화 되면서 값이 바뀌게 되겠죠
ex) $("p").addClass("myClass");
(select).removeClass(className)
ex) $("p").removeClasss("ClassName");
(select).attr(attributeName)
(select).attr(attributeName, value)
(select).removeAttr(attributeName)
이 두함수는 선택된 엘리먼트의 속서값을 가져오거나 설정할 수 있도록 합니다.
<!DOCTYPE html>
<html>
<head>
<style>em { color:blue; font-weight;bold; }
div { color:red; }</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<p>
Once there was a <em title="huge, gigantic">large</em> dinosaur...
</p>
The title of the emphasis is:<div></div>
<script>var title = $("em").attr("title");
$("div").text(title);
</script>
</body>
</html>
<img id="greatphoto" src="brush-seller.jpg" alt="brush seller" />
$('#greatphoto').attr('alt', 'Beijing Brush Seller');
$('#greatphoto')
.attr('title', 'Photo by Kelly Clark');
$('#greatphoto').attr({
alt: 'Beijing Brush Seller',
title: 'photo by Kelly Clark'
});
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<button>Enable</button>
<input type="text" disabled="disabled" value="can't edit this" />
<script>
$("button").click(function () {
$(this).next().removeAttr("disabled")
.focus()
.val("editable now");
});
</script>
</body>
</html>
펌) $(this).next() 코드로.. 형제노드에서 다음 노드를 구하니까.. <input>을 먼저 구하고.<input> 엘리먼트의 disabled 속성을 제거하고... 포커스를 주고.. val('editable now') valut="editable now'와 같은 일을 합니다... 그러니... 클릭하면.. 입력창이 활성화 되면서 값이 바뀌게 되겠죠
댓글
댓글 쓰기
질문이나 의견은 요기에 남겨주세요 ^^,,