ããã«ã¡ã¯ããã«ã¡ã¯â¦ï¼
çªç¶ã ãã©ä»æ¥ã¯ã¡ãã£ã´ããã³ã·ã§ã³ä½ãã«ã
è¦ç´ ã®ã¹ã¯ãã¼ã«ã«ã¤ãã¦ã®ãæéãªãã§ãâ¦ï¼
- ãºã
- ãºããºã
- ãºããºã
- ãºããºã
- ãºããºã
<div style="height:4em; overflow-y:scroll"> <ul id="peroZone"> <li>ãºã</li> <li>ãºããºã</li> <li>ãºããºã</li> <li>ãºããºã</li> <li>ãºããºã</li> </ul> </div> <input type="button" value="ãºãã©ã¤ã³è¿½å " onclick="add()" />
âãªãããããããã¤ããã£ã¦â¦ã
ãã¿ã³ãæ¼ããã³ã«ããºããºãã¨ãªã¢ã®ä¸çªä¸ã«è¡ã追å ããããããªä»æããä½ãããã¨ãâ¦ã»ã
<script> function add() { // è¡ã追å ããã var peroZone = document.getElementById('peroZone'); var li = document.createElement('li'); li.appendChild(document.createTextNode('追å ããããºãã')); peroZone.appendChild(li); } </script>
â¦ãããªãµãã«æ®éã«JavaScriptã§é©å½ã«ä¸çªä¸ã«è¡ã追å ãã¦ãã
ãã¶ãã¹ã¯ãã¼ã«ãã¼ã¯ä¸çªä¸ã«ãã£ã¤ããã¾ã¾ã«ãªã£ã¡ããâ¦ã
â¦
ã¡ãã£ã¨æ©ãã ããããã¼ãã®èãã¤ããããã¾ãããããããªãããæ¹ã¯ãããªæãâ¦ã
<div style="height:4em; overflow-y:scroll"> <ul id="peroZone"> <li>ãºã</li> <li>ãºããºã</li> <li>ãºããºã</li> <li>ãºããºã</li> <li>ãºããºã</li> </ul> <!-- âã¤ãããããã¤â¦ --> <input id="eom" type="text" style="width:1px; height:1px; disaply:none"> </div> <input type="button" value="ãºãã©ã¤ã³è¿½å " onclick="add()" />
ãºããºãã¨ãªã¢ã®æä¸è¡ã«ããã¼ã®inputãé
ç½®ãã¦ããã¦è¦ããªããã¦ããã¦â¦
ããã§ãè¡ã追å ãããã³ã«ããã¼ã®inputãfocusãã¦ã¿ããâ¦ã
<script> function add() { // è¡ã追å ããã var peroZone = document.getElementById('peroZone'); var li = document.createElement('li'); li.appendChild(document.createTextNode('追å ããããºãã')); peroZone.appendChild(li); // é ãinputãfocusããã document.getElementById('eom').style.display = 'inline'; document.getElementById('eom').focus(); setTimeout(function() { document.getElementById('eom').style.display = 'none' }, 100) } </script>
ãã¨ãã©ã¦ã¶ã«ãã£ã¦ã¯ã
å
¥åæ¬ã®ã«ã¼ã½ã«ãã¡ãã»ãã¨è¦ãã¦ãããã
表示ããã¦ããªãè¦ç´ ã«focusã§ããªãã£ããããããã
focusããç¬éã ã表示ããããã«ç¡é§ã«æªããããã¦ã¿ããâ¦ã
(ãµã³ãã«ãã¼ã¸)
overflow-y:scrollãªè¦ç´ ãä¸çªä¸ã¾ã§ã¹ã¯ãã¼ã«ãããã©ããã¾ãã¡ã±ã£ã¨ããªããµã³ãã«
â¦ãªãããããªã®ããæãã¤ããªãã£ããã ãã©ã
ãã£ã¨ã¡ããã¨ããã«ã¯ãã©ãããã°ãããã ãããâ¦ï¼
(追è¨)
解決ãã¾ããï¼ ãããã¨ãï¼ï¼
詳ããã¯ã³ã¡ã³ãæ¬ã§ãï¼