I have some code which links to 2 different pages. When you are on one page the other one is a link. eg
<div id="options">
<a href="#">other</a>
<p>current</p>
</div>
<div id="options">
<p>current</p>
<a href="#">other</a>
</div>
I want to execute an if statement if a is the last child but not sure of the correct syntax?
eg
if {/* #options a is last child*/}
{
alert("hello");
}
You can check if an element matches a pseudo-selector by using the
.is()function:It ends up being pretty readable.
Demo: http://jsfiddle.net/acWUT/