According to the school guidelines, jquery, in order to get an element of the brother, you can use Prev (), Next () two methods. As the name implies, Prev () Gets the previous one, next () gets the back one.
The problem is that if there are brothers before and after, the two methods may return real deal objects; return what? Is it null?
The answer is no. If you want to use if ($ ("#div1"). Prev () = = null) {alert ("No");}, destined to hit the board. Because it will never be null.
I tried it and tried it, and I ended up doing it this way:
if (typeof $("#div1""undefined") { alert("没啦"); }
Most hate online those articles, a big copy, a piece of oath, but only to say something known, not practical, the key moment unreliable.
Get a sibling's usage scenario, such as a page sign. Click on a tab, will this be the first one or the last one?
Copyright NOTICE: This article for Bo Main original 屙 article, like you take away.
jquery gets sibling elements