【发布时间】:2016-02-13 11:28:21
【问题描述】:
fetch_customer_info.php
<button id=printToTextarea>Get to box</button>
text.php
<?php
require_once('fetch_customer_info.php');
?>
<script type="text/javascript">
$("#printToTextarea").on("click", function () {alert(3);
$(this).next("#textInput").focus();
});
</script>
<div id="projectNameDiv">
<label for="textInput">Text to Print:</label><br/>
<textarea name="textInput" id="textInput" rows='3' cols='40'></textarea>
</div>
当我单击“进入框”按钮时,没有出现警告消息。我需要关注文本区域。
【问题讨论】:
-
显示 HTML 的其余部分。此外,您无需使用
next(),因为您正在尝试查找id,只需使用$('#textInput').focus() -
@powerbuoy 没用
-
我不喜欢在单个文件中同时使用这两个部分。