0
드롭 다운에서 선택한 요소를 결정하기 위해 "choice"변수를 선택하려고합니다. 문제는 "슬로건"을 클릭 한 다음 "헤더"로 돌아가서 두 텍스트 필드에 모두 쓰기 시작할 때입니다. 당신이 새로운 이벤트 핸들러 input
요소에 부착 된 change
이벤트마다 이벤트 처리기를 바인딩되어 있기 때문에선택 상자 변경시 if-else 문
HTML
<select class="choice">
<option value="h">Header</option>
<option value="s">Slogan</option>
</select>
<input class="selecttext" type="text" placeholder="Main Text"></input>
자바 스크립트
$(".fontsdiv .choice").on("change", function() {
var choice = $(".choice").val();
if (choice === "h") {
$(".selecttext").keyup(function(event) {
var titlechange = $(".selecttext").val();
$(".maintitle").html("<h1 class='maintitle'>" + titlechange + "</h1>");
$(".maintitle").draggable();
});
} else if (choice === "s") {
$(".selecttext").keyup(function(event) {
var titlechanges = $(".selecttext").val();
$(".secondtitle").html("<h1 class='secondtitle'>" + titlechanges + "</h1>");
$(".secondtitle").draggable();
});
}
});
onchange' .. 즉이 값이 * * ... 어쩌면 경우에 대응하기 위해 거기에 또 다른 조건문을 넣어 변경 될 때 어떻게해야되는 것입니다 'choice! == "h"'? –
뭘하고 싶은가요? 문제가 있습니까? –