테스트 사이트 - 개발 중인 베타 버전입니다

버튼누르면 입력창에 치던글씨 글씨체 바꾸기 채택완료

rlawhd 7년 전 조회 4,942

옆에 있는 버튼을 누르면 input type="text" 에 있는 글자의 글씨체가

 

bold나 이탤릭체로 바꾸게 하고 싶습니다.

 

</p>

<p><button type="button" id="bold">BOLD</button></p>

<p><input type="text" id="maintext" /></p>

<p> </p>

<p>$("#bold").click(function(){

??

});</p>

<p>

 

jquery시에 저기에 뭘 넣어야할까요?

생각해본것은

message = $("#maintext").html(""); $("#maintext") = message;

 

이건데..

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
7년 전

$("#maintext").css("font-weight", "bold");

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

r
rlawhd
7년 전
감사합니다. 혹시 누른걸 다시 끌때 돌아오는데
다시 킬떄 STYLE=""이 있어서 안되는데 어떡하면 좋을까요

$("#bold").click(function(){
if($("#maintext").is("[style]")){
$("#maintext").css("font-weight", "");
}else{
$("#maintext").css("font-weight", "bold");
}
});
슈와이
7년 전
var boldPressed = false;
$("#bold").click(function() {
$("#maintext").css("font-weight", boldPressed ? "normal" : "bold");
boldPressed = !boldPressed;
});

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인