나는 자바 스크립트를 안다. 작은 스크립트를 결합하여 &을 변환하여 대부분의 요구 사항을 달성했습니다. 그러나 아래에 설명 된 요점에서 나는 나의 요구 사항을 완전히 해결할 수 없었다.
내 상수 텍스트 앞에 하이퍼 링크 ID 값을 인쇄하려고합니다.jquery를 사용하지 않습니다. 단지 쓰고 당분간 예
"당분간로 응답하고있다."
단 (하이퍼 링크 ID = 6을 가정)는 6의해 회신되는 "작성해야 당분간 "
내가 읽은이 SO Q & A 그러나 나는 그것으로부터 이익을 얻을 수 없었다. 당신이 LinkId.value = id
톤을 추가 결코처럼 몸 태그 (JS: How to concatenate variables inside appendChild()?)
DEMO FOR THE CURRENT STATE @JSFIDDLE
JS
function reply_comment (id) {
var LinkId = document.getElementById('parent_id');
LinkId.value = id;
var message = document.createTextNode(" is being replied by the time being.");
document.getElementById('print_id').appendChild(message);
document.getElementById("focus_id").focus();
}
HTML은 나에게
<!-- codes given above -->
<script type="text/javascript">
... ... ...
</script>
<!-- codes given above -->
<!-- when clicked on the hyperlink, store the hyperlink id value (id value is an unsigned integer) -->
<!-- print the stored id from hyperlink into the value="{unsigned integer id}" part of input (type:text and id="parent_id")-->
<!-- focus on comment form's input (type:text and id="focus_id") -->
<!-- print preset message between span tags (span tag id="print_id" ) -->
<a class="rep" href="#focus_id" onclick="reply_comment(this.id);" id="6" rel="nofollow">reply comment</a>
<p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p>
<span id="print_id"></span>
<form>
<label for="focus_id">Focus the cursor below</label>
<input type="text" id="focus_id" name="focus_id">
<label for="parent_id">Paste parent_id below</label>
<input type="text" id="parent_id" name="parent_id" value="">
</form>
나는 JS에 대해 무지하다는 말을했습니다. 감사합니다. –