I am trying to reproduce the lock function on posts on facebook with jquery and php/mysql.
Below is an image showing the different actions it does when clicked on.
I think you would do somehing like on hover, show a hidden div with a tooltip, on hover off remove it. On click event show another hidden div but somehow has to change the button’s colors as well. When the menu div is clicked open it has a menu and if any of these are clicked it needs to send the result to backend script with ajax. After clicking an option or clicking outside of the divs it will hide all the divs, maybe it is just a click anywhere closes it so maybe a toggle can be used?
Can anyone clarify I am going in the right direction. I havent used jquery very much or javascript. Any examples of something like this or help would be greatly appreciated.
fb http://img2.pict.com/ed/9a/3a/2341412/0/screenshot2b166.png
You don’t need JavaScript for the hover. Make an element that serves as your tooltip and position it above your dropdown button. Then make a parent
<div>for both. Your HTML should look something like this:Once you’ve done that, you can use CSS to position the tooltip and show it when necessary.
To show the drop-down box, you probably will need JavaScript. Add another element to the container:
Position it as you like using
position: absoluteand hide it usingdisplay: none. Then show it when we click on the button:You can then make your sub-items do whatever they like, as long as they also hide
#selection.Finally, you want to change the background and text colours upon hover. That’s easy enough:
This won’t work perfectly in IE 6 or (I believe) 7 – you’ll need to investigate alternative solutions for that. Either use JavaScript or check out IE7.js and IE8.js.