teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

コードの追加

2016/11/04 06:39

投稿

nobinobi
nobinobi

スコア199

answer CHANGED
@@ -28,4 +28,37 @@
28
28
 
29
29
  上記では単純にdivの中身を取得してtextareaの中に挿入するだけです。
30
30
 
31
- 作成されたリッチエディタの情報を載せると他の回答が得られると思いますよ。
31
+ 作成されたリッチエディタの情報を載せると他の回答が得られると思いますよ。
32
+
33
+
34
+ ---
35
+
36
+
37
+ **コード追加**
38
+ ```
39
+ <html>
40
+ <head>
41
+ </head>
42
+ <body>
43
+ <script type="text/javascript">
44
+ function myClicked() {
45
+ var edit_value = document.getElementById('cursor').value;
46
+ //var edit_value = document.getElementsByClassName('edit_area');
47
+ var textarea_str = edit_value;
48
+ //var textarea_str = edit_value[0];
49
+ document.example_form.example_textarea.value = textarea_str;
50
+ //document.example_form.example_textarea.value = textarea_str.innerHTML;
51
+ }
52
+ </script>
53
+
54
+ <form name="example_form">
55
+ <div id="edit_area" class="edit_area"><input type="text" id="cursor" class="cursor"></div>
56
+ <div class="edit_area" style="visibility:hidden;"><span style="font-size:20px;color:#00FF00;">hoge</span></div>
57
+ <div id = "myClickee" onclick="myClicked();">ここをクリック!</div>
58
+ <textarea id="sample" name="example_textarea"></textarea>
59
+ <p id="log"></p>
60
+ </form>
61
+
62
+ </body>
63
+ </html>
64
+ ```