npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery.cssselect

v2.0.1

Published

Keyboard-aware custom <select> dropdown boxes without inline styles. UMD-compatible – for your <script> tag with jQuery on the page, AMD module loader, or CommonJS.

Downloads

54

Readme

Build Status

cssSelect

Keyboard-aware custom <select> dropdown boxes without inline styles. UMD-compatible – for your <script> tag with jQuery on the page, AMD module loader, or CommonJS.

Keep your dropdown styling in the stylesheet(s).

Introduction

cssSelect takes an existing <select> as its argument and generates the following markup by default:

<div class="select name-{original-select-name}">
  <a class="selected" data-option-value="{selected option value}">
    <span class="text">{selected option text}</span>
    <span class="handle"></span>
  </a>
  <ul>
    <li data-option-value="{original first option value}">{original first option text}</li>
    <li data-option-value="{original second option value}" class="selected">{original second option text}</li>
    <li data-option-value="{original third option value}">{original third option text}</li>
  </ul>
</div>

The example above shows the second of three options being selected, hence the class selected on the second item in the list.

This markup is placed adjacent to the original <select> in the DOM tree. The original <select> is also given the class hidden.

It's probably ideal to place the select off-screen at this point with some CSS, e.g.:

.hidden {
  text-indent: -999em;
}

You'll also want to style the new .select on the page - cssSelect's philosophy is that it should not add any inline-styling to elements on the page. all of that stuff should stay in stylesheet(s) so that it's easy to modify and override.

Usage

cssSelect can be used as a jQuery plugin:

$('select#customizable-select').cssSelect();

If you're using some kind of module-loader, it is also exposed as a standalone function:

var cssSelect = require('jquery.cssselect');
cssSelect('select#customizable-select');

CommonJS-style module loader pictured above, but the same should work for an AMD-style loader.

Using a module loader allows you to hide the jQuery dependency, so your module that depends on cssSelect will be able to operate without declaring jquery as a dependency in that module.

Contributing

Write issues/submit pull requests. I'm very interested in issues that people may have and making this as good as it can possibly be.

If you're submitting pull requests, make sure you run/update/add tests: npm test

npm install beforehand to get the project's development dependencies.