开发者

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

开发者 https://www.devze.com 2023-01-08 13:47 出处:网络
How do i focus a input type=\"text\" automatic when my id changes in page url ? For example: http://mysite.php?id=2

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

精彩评论

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