last()方法返回所選元素的最后一個元素。
要返回第一個元素,請使用first()方法。
$(selector).last()
突出顯示最后一段:
$(document).ready(function(){ $("p").last().css("background", "coral"); });測試看看?/?
在最后一個DIV元素內(nèi)突出顯示最后一個段落:
$(document).ready(function(){ $("div p").last().css("background", "coral"); });測試看看?/?
突出顯示最后一個無序列表:
$(document).ready(function(){ $("ul").last().css("background", "coral"); });測試看看?/?