0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

クリックイベント

Posted at

クリックイベントを起こす時の定型
以下では「#result」に文字を表示させている

$(function(){
	$("#target").click(function(){
		$("#result").text("クリックしました");
	})
});
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>イベント</title>
    <!-- jQuery -->
    <script src="js/jquery.min.js"></script>
    <!-- 外部CSS/JavaScript -->
    <link rel="stylesheet" type="text/css" href="css/main.css" />
    <script src="js/main.js"></script>
  </head>
  <body>
    <h1 id="target">イベント</h1>
    <h1 id="result"></h1>
  </body>
</html>

ちなみに以下の引数なしの場合はクリックを強制で行えるらしい

$(function(){
	$("#target").click();
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?