我想在facebook墙上激活textarea。我试过.focus()但没有工作。有没有办法用javascript或visualbasic点击它?
答案 0 :(得分:1)
答案 1 :(得分:0)
<html>
<head>
<script>
window.onload = function() {
document.getElementById("textArea").focus();
};
</script>
</head>
<body>
<form>
<input type="textarea" id="textArea">
</form>
<body>
</html>
答案 2 :(得分:0)
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script language='javascript'>
$( document ).ready(function() {
$("#result").html("Click Now");
$('#tarea').focus(function(){
$("#result").html("Textarea Clicked");
});
});
</script>
<body>
<textarea rows="4" cols="50" id='tarea'></textarea>
<p id='result'></p>
</body>
</html>
答案 3 :(得分:-1)
document.getElementById('textAreaId').focus();
应该有用。
如果您希望在页面加载时聚焦textarea,您可以向html元素添加autofocus
属性