top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to add the previous selection to the current selection using jQuery?

0 votes
543 views
How to add the previous selection to the current selection using jQuery?
posted Jul 28, 2017 by Biswajit Maity

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Your question is not clear to me and assuming that you are looking to add the element along with its previous sibling.

As Mani has pointed out you can use the addBack function -
$('#QH-codes-label').prev().addBack()

Where #QH-codes-label is the id for which you want the previous element (sibling)

1 Answer

0 votes

You can use addBack()

$('#search-form #QH-codes-label').prev().addBack()

Since id will be unique you can shorten it to

$('#QH-codes-label').prev().addBack()
answer Aug 7, 2017 by Manikandan J
What is search-form and QH-codes-label
...