私はJSで一種の画像ギャラリーを構築しました。指定された img 要素と p 要素で、onmousedown イベントは 2 つの関数を呼び出します: 新しい画像と新しい説明を読み込みます (以下を参照)。
しかし、私が考えていたのとは反対に、右クリックでも onmousedow がトリガーされます。私はこれが好きではなく、onmousedown イベントをマウスの左クリックに限定したいと思っています。
これを行う方法はありますか?
助けてくれて本当にありがとうございます。
HTML:
<img style="max-width: 100%; cursor:pointer;" src="../../img/picture1.jpg" alt="text" title="click me"
id="showgallery" onmousedown="changeimg(); changedscrpt()" />
enter code here
<p class="myclass" style="text-align: center;" id="imgdescription">Description</p>