writes the value of the current value sibling elements with jquery second node - the front end face of questions often test & compulsory

Problem: value value of the second node with jquery write sibling of the current element? ? ?

Analysis: The title has a pit, that is, if the current element without a second sibling it (pit pit pit)

Resolution:

Generally, we might write:

$ (the this) .siblings () EQ (. 1) .val ();.   // second node of the sibling node element value

 

But for this pavement questions we need to write:

var nod=$(this).siblings().eq(1);

if(nod.length<1){

return "";

}else{

return nod.val();

}

Guess you like

Origin www.cnblogs.com/snowbxb/p/11539857.html