Skip to content

Wish you could stye more :hover? Add CSS classes to clicked items.

License

Notifications You must be signed in to change notification settings

madkap/jq-selected

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#jq-selected

Wish you could stye more than :hover with CSS? Add CSS classes to recently clicked items and boldly let CSS handle mundane tasks normally handled by javascript.

Whut? Why?

I got tired of scripting .click events in javascript for things like drop-down menus, tooltips, popups, modals, etc.

jq-selected adds classes to recently clicked items so you easily can apply CSS -- and CSS animations!

When targeted item is clicked, it gets the class "selected" and either the class "odd" or "even" depending on the number of times it was clicked.

Usage

Add this to your document.ready

$(".foo").selected()

Foo can be whatever.

Now, when .foo is clicked, it gets the class selected and either the class odd or even depending on the number of times it was clicked.

Other items that begin with the same class as the .foo you clicked (can be .foo or any other class) are toggled, you can style only the most recent item "with even or odd" or all of them with "selected".

Styling could go something like this:

.foo.selected {
	color: red;
}

.foo.selected.odd {
	color: blue;
}

.foo.selected.even {
	color: green;
}

About

Wish you could stye more :hover? Add CSS classes to clicked items.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published