| 1. |
Why To Use “siblings” Method? Give Sample Code To Demonstrate The Same? |
|
Answer» When we need to GET the list of SIBLING elements then “sibling” method is used on parent element. Selectors can be used to filter the siblings. For example <UL> <li> itemA </li> <li id=”mycontrolID”> itemB </li> <li class=”mycontrolclass”> itemC </li> <li class=”mycontrolclass”> itemD </li> </ul> $(‘li#mycontrolID’).siblings().css(‘color’,’YELLOW’); When we need to get the list of sibling elements then “sibling” method is used on parent element. Selectors can be used to filter the siblings. For example <ul> <li> itemA </li> <li id=”mycontrolID”> itemB </li> <li class=”mycontrolclass”> itemC </li> <li class=”mycontrolclass”> itemD </li> </ul> $(‘li#mycontrolID’).siblings().css(‘color’,’yellow’); |
|