클릭 할 때마다 div
의 텍스트를 변경하려고합니다. 다음을 시도했지만 작동하지 않습니다.div()에서 언제든지 .append()를 click()과 함께 사용
<script>
$(document).ready(function() {
//alert('hi');
$('div').css('cursor','pointer')
$('div').append('hi')
$('div').click(function() {
if ($(this).html('hi') {
$(this).html('how r u');
}
if ($(this).html('how r u')) {
$(this).html('hi');
}
)
//$(this).html('how r u');
})
})
</script>
아무도 도와 줄 수 있습니까?
미리 감사드립니다
귀하의 예제 코드는 구문 오류의 몇 가지가 있습니다 - '$ ("div") .Click (fn)'다음에 닫는 중괄호가 빠졌고 스크립트의 마지막에 대괄호와 중괄호가 추가되었습니다. –
토글 하시겠습니까? '$ ("div"). toggle (function() {$ this) .html ("안녕하세요"), function() {$ (this) .html ("How are you? $ ("div"). trigger ("click");' –