Skip to content

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

Notifications You must be signed in to change notification settings

jtwalters/jquery-focused

Repository files navigation

jQuery Focused

Usage

  1. Include jQuery:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
  1. Include plugin's code:
<script src="dist/jquery.focused.min.js"></script>
  1. 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)
  }
});

Contributing

Check CONTRIBUTING.md for more information.

License

MIT License © Joel Walters

About

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

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published