jquery click() method


  Translation results:

click

英[klɪk] 美[klɪk]

n. Click; claw, detent; [meter] (mouse) click; [ Linguistics] Inspiratory sound

vt. Make a clicking sound

vi. Make a clicking sound; extremely successful; get along well, hit it off at first sight; [plan] rat strike

jquery click() methodsyntax

Function:When an element is clicked, the click event will occur. A click occurs when the mouse pointer is over an element and the left mouse button is pressed and released. The click() method triggers a click event, or specifies a function to run when a click event occurs.

Trigger click event syntax: $(selector).click()

Bind the function to the click event syntax: $(selector) .click(function)

Parameters:

##ParameterDescriptionfunction Optional. Specifies a function to run when a click event occurs.

jquery click() methodexample

<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(){
  $("button").click(function(){
    $("p").slideToggle();
  });
});
</script>
</head>
<body>
<p>这是一个段落。</p>
<button>切换</button>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Popular Recommendations