---
title: "Select previous element using jquery selector only"  
description: "Select previous element using jquery selector only"  
author: "Anonymous User"  
published: 2013-05-09  
updated: 2013-05-09  
canonical: https://www.mindstick.com/forum/846/select-previous-element-using-jquery-selector-only  
category: "jquery"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# Select previous element using jquery selector only

Hi Guys!\
How to [select previous](https://www.mindstick.com/forum/156674/select-previous-sibling-via-jquery) [element using jquery](https://www.mindstick.com/forum/158691/how-can-you-change-the-css-styles-of-an-element-using-jquery) [selector](https://www.mindstick.com/interview/23419/action-selector-in-mvc) \
My HTML Line of code:\
<li class="collapsable"> <div class="hitarea collapsable-hitarea"></div> <span id="devicelist" class="ankr">[Device](https://www.mindstick.com/blog/149/retriving-network-device-information-in-c-sharp) List</span> <ul id="ultree"> <li type="dev" device="/dev/sdh1" id="dev0" class="litab"> <img height="20px" width="20px" src="../Images/drive.png" class="dicon"> <a class="ankr dn" href="#">'/dev/sdh1'</a> </li> </ul></li>\
My Jquery line of code:\
$([document](https://www.mindstick.com/articles/328642/what-to-consider-while-choosing-a-software-documentation-tool)).on("click","#devicelist,**Here Selector will be used**",this,[function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server)(event){ console.log(this); console.log(event.target); });\
I want to select div which has [class name](https://www.mindstick.com/forum/12871/how-to-get-class-name) as "hitarea"\
I want to something like $("#devicelist: Somethis here write to select div.hitarea")\
It should be done only selector of jquery.\
How can i do this?\
Any [succession](https://answers.mindstick.com/qa/107655/what-are-the-causes-of-the-war-of-spanish-succession) will be welcome!\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi Ben!\
you can use the prev() selector\
Description: Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.\
$('#devicelist').prev();


---

Original Source: https://www.mindstick.com/forum/846/select-previous-element-using-jquery-selector-only

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
