jquery get one slibling above the current element in javascript

To get the immediate sibling element just above the current element using jQuery, you can use the .prev() method in combination with .first() method. The .prev() method will select the immediately preceding sibling of the current element, while the .first() method will reduce the set of matched elements to the first one in the set.

Here's the code snippet to achieve the same:

index.tsx
$(document).ready(function(){
  $("#current_element").prev().first();
});
74 chars
4 lines

In the above example, #current_element is the selector for the current element, you should replace it with your own selector depending on your use case.

gistlibby LogSnag