jquery target attribute
Translation results:
target
UK[ˈtɑ:gɪt] US[ˈtɑ:rgɪt]
n. Target; purpose; (service) object; (shooting) Target
vt. Aim; take... as an attack target
jquery target attributesyntax
Function:The target attribute specifies which DOM element triggered the event.
Syntax: event.target
Parameters:
Parameters | Description |
event | Required. Specifies the events that need to be checked. The event parameter comes from the event binding function. |
jquery target attributeexample
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p, button, h1, h2").click(function(event){ $("div").html("点击事件由一个 " + event.target.nodeName + " 元素触发"); }); }); </script> </head> <body> <h1>这是一个标题</h1> <h2>这是另一个标题</h2> <p>这是一个段落</p> <button>这是一个按钮</button> <p>标题、段落和按钮元素定义了一个点击事件。如果您触发了事件,下面的 div 会显示出哪个元素触发了该事件。</p> <div></div> </body> </html>
Click the "Run instance" button to view the online instance
Popular Recommendations
- AI-Generated Crypto Scams Target Apple Fans
- property target does not exist on type HTMLInputElement
- XRP’s Ambitious $100 Price Target: A Deep Dive
- DOGE Price Prediction: These Levels Are the Target for the Altcoin!
- Bitcoin ATM Fraud Scams Target Elderly, Clay County Sheriff’s Office Warns
- Bittensor (TAO) Price Surges 40%: Analysts Predict Bullish Continuation and $600 Target