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

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

QA

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

본문

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

 

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

 


<button type="button" id="bold">BOLD</button>
<input type="text" id="maintext" />
 
$("#bold").click(function(){
??
});

 

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

생각해본것은

message = $("#maintext").html("<b>");
$("#maintext") = message;

 

이건데..

이 질문에 댓글 쓰기 :

답변 1

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

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

$("#bold").click(function(){
if($("#maintext").is("[style]")){
$("#maintext").css("font-weight", "");
}else{
$("#maintext").css("font-weight", "bold");
}
});

답변을 작성하시기 전에 로그인 해주세요.
전체 56
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT