jQuery Focused

Simplify pages by focusing in on relevant items, based on values of elements (e.g. select, input, textarea).

This project is maintained by jtwalters

jQuery Focused

Usage

  1. Include jQuery:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    
  2. Include plugin's code:

    <script src="dist/jquery.focused.min.js"></script>
    
  3. Call the plugin:

    $('#content').focused({
      // attr: {string} attribute to use as selector
      attr: 'data-focus',
    
      // changeElement: {jQuery object or selector} to bind the change event handler to
      changeElement: 'select[name=focus]',
    
      // bindChange: {boolean} whether we should update on change event (if false, only updates on initialization)
      bindChange: true,
    
      // value: (optional) {function} to modify the value before using it
      value: null,
    
      // afterUpdate: (optional) {function} to run after the value has changed
      afterUpdate: function focusTransition() {
        $('.focus-wrapper:visible').hide().fadeIn(400)
      }
    });
    

Demo

Demo 1 - Select

Contributing

Check CONTRIBUTING.md for more information.

License

MIT License © Joel Walters