checkout this code snippet - https://jsfiddle.net/johndoe1994/xtu09zz9/
Let me explain the functionality of the code
The code contains two containers: .first
and .second
. The .first
container has two default divs with a class of .item
. The .second
container starts empty.
When you hover over each .item
, you will see bootstrap glyphicons in the shape of hearts.
If you click on an .item
, it will move to the .second
container. When you hover over the .item
in the .second
container, the heart glyphicon will change to a minus sign.
Although the code looks good, there is a small issue with the jQuery part.
In the current implementation, all clicks on the .item
container trigger a clone() action to the .second
container. However, the desired behavior is to only trigger the clone() when clicking on the glyphicon inside the .item
container. Here is where I need help tweaking the jQuery code.
Should I use the parent() method or another jQuery method like closest() or has()? Your assistance would be greatly appreciated.
Please assist me with resolving this issue.