SEMrush

Tuesday, 8 November 2016

last() function in JQuery


last() in JQuery


The last() in jquery is used to select the last element. Particularly this is used when the user wish to apply style to last child of an particular element.The syntax to do this is given below

$(selector).last();

$(selector).last().css("property","property-value"); 


( to change the css property of last element)  

eg:- $("#fruits").last().css("background-color","green");

$(selector).last().remove(); 

(will remove the last child of selected element)



No comments:

Post a Comment