Skip to content

jstools/jq-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2739fc4 · Jun 24, 2016

History

44 Commits
Mar 8, 2016
Apr 27, 2015
Apr 27, 2015
Oct 14, 2015
Apr 27, 2015
Oct 14, 2015
Oct 15, 2015
Mar 8, 2016
Mar 8, 2016
Mar 8, 2016
Oct 14, 2015
Mar 8, 2016
Jun 24, 2016
Jun 24, 2016

Repository files navigation

jEngine: jq-plugin

Bower version npm version Build Status

Installation

npm install jq-plugin --save

or

bower install jq-plugin --save

Demo

http://plnkr.co/edit/NSaBssbFXBjDcIRljy92?p=preview

http://codepen.io/jgermade/pen/YyrRGL?editors=101

Usage

$.plugin

<button class="click">Click Me</button>
$.plugin('button.click', function () {
  var jBtn = $(this),
      alt = false;

  jBtn.click(function () {
    alt = !alt;
    if( alt ) {
      jBtn.text('it works!');
    } else {
      jBtn.text('Click Me');
    }

  });
});

$.widget

<div data-widget="test">
  <ul>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
  </ul>
</div>
$.widget('test', function () {
  console.log('widget', this);

  $(this).find('li').hover(function() {
      this.style.fontWeight = 'bold';
    }, function() {
      this.style.fontWeight = 'normal';
    });
});