어떻게해야하나요? 여기 내 스크립트
$('code').on('click', function(){
var cursorPos = $('#spot-template-code').prop('selectionStart');
var v = $('#spot-template-code').val();
var textBefore = v.substring(0, cursorPos );
var textAfter = v.substring( cursorPos, v.length );
$('#spot-template-code').val( textBefore+ $(this).xml() +textAfter );
});
어떻게 변경해야하나요? 기능을 클릭 한 후 내 텍스트 영역에 아무 일도 일어나지 않았습니다.
<trans data-id='AFTER'>AFTER</trans>
이 코드를 텍스트 영역에 삽입하고 싶습니까?
좋아, 태그에 코드를 입력하고 컨트롤의 html에 액세스하면됩니다.
$('[data-id="AFTER"]').click(function(){
$('#txtCode').val($('#copy').html())
});
<script
src="https://code.jquery.com/jquery-3.4.1.js"
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
crossorigin="anonymous"></script>
<script id="copy">
$('code').on('click', function(){
var cursorPos = $('#spot-template-code').prop('selectionStart');
var v = $('#spot-template-code').val();
var textBefore = v.substring(0, cursorPos );
var textAfter = v.substring( cursorPos, v.length );
$('#spot-template-code').val( textBefore+ $(this).xml() +textAfter );
});
</script>
<trans data-id='AFTER'>AFTER</trans>
<textarea id="txtCode"></textarea>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다