开发者

How do i focus a input type="text" when my id changes in page url?

How do i focus a input type="text" automatic when my id changes in page url ?

For example: http://mysite.php?id=2

I want to focus the mouse on my type="text" when my PHP IF statement is met without using buttons.

<form>
&l开发者_StackOverflow中文版t;input type="text">
</form>

It should go something like: php IF (condition) { focus the mouse to input type="text" based on id of url }


You mean this:

<?php
  if (intval($_GET['id']) === 1) // adjust value
  {
?>

<script type="text/javascript">
  // focus element
  var el = document.getElementById('elem_id');
  el.focus();
</script>

<?php } ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜