jquery get() method


  Translation results:

get

英[get] 美[ɡɛt]

vt. Get; catch; persuade; receive (punishment, etc.)

vt.& vi. Arrive, come

vi. Become; start; try to deal with; obtain benefits or wealth

n. Reproduce, cub; profit

jquery get() methodsyntax

Function: get() method obtains the DOM element specified by the selector.

Syntax: $(selector).get(index)

Parameters:

ParameterDescription
index Optional. Specifies which matching element to retrieve (via index number).​

jquery get() 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(){
    x=$("p").get(0);
    $("div").text(x.nodeName + ": " + x.innerHTML);
  });
});
</script>
</head>
<body>
<p>This is a paragraph</p>
<button>获得 p DOM 元素</button>
<div></div>
</body>
</html>
Run instance »

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

Popular Recommendations

Home

Videos

Q&A