Bind the click event
Bind click event to an element, you can use the following method:
$ ( '# btn1'). the Click ( function () { // inside this refers to the native objects // use jquery object with $ (this) })
Gets the index value of the element
Sometimes the need to obtain the position of the index matching elements relative to its fellow element, can be used at this time index () method to get
var $li = $('.list li').eq(1); alert($li.index()); // 弹出1 ...... <ul class="list"> <li>1</li> <li>2</li> <li>4</li> <li>5</li> <li>6</li> </ul>
Exercise:
Tab