1
저는 JQuery를 처음 접했습니다. 지금 당장은 매우 어려운 위치에 있습니다. 사용자가 원하는 단락을 작성하고 브라우저에서 텍스트 편집과 같이 원하는 단락의 텍스트 만 변경할 수 있도록해야합니다.단락 선택 스타일 변경
$('#redText').click(function() {
change_color('red');
});
$('#blueText').click(function() {
change_color('blue');
});
function change_color(theColor) {
//What should I put here to make any selected text change the color ?
}
중요 정보
.par {
width: 300px;
height: 300px;
border: 2px solid #A3A3A3
}
JS
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-5589-1" />
<link rel="stylesheet" href="style_ext.css">
<title>Editable Paragraph</title>
</head>
<body>
<p contenteditable="true" class="par" id="txt">This is an editable paragraph.</p>
<center>
<button type="button" id="redText">Color text in red</button>
</center>
<center>
<button type="button" id="blueText">Color text in blue</button>
</center>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/pushred.js"></script>
</body>
</html>
CSS : 여기 내 파일입니다 : 난, 전체 단락 변경 내가 http://api.jquery.com/select/을 봤
텍스트 편집기처럼 만 세그먼트 선택을하지 않습니다. 그것은>이 이벤트는''필드와'
그래, 나는 똑같은 것을 발견했다. 그러나 내가 원했던 것은 텍스트를 가져 오는 것뿐만 아니라 스타일을 굵은 글씨, 밑줄 칠하기 등등을 적용하고 싶다. 그리고 나는 입력이되어서는 안된다. 일반 HTML로 5 개 또는 6 개의 단락을 전송합니다. 즉, 간단한 텍스트 편집기를 만들고 싶습니다. – Avulsed