Monday, February 13, 2017

jQuery Functions for showing and hidding things with Buttons!


I'd like to use hide() and show() for the Load Data Menu in EISPP.

With respect to, "JavaScript and JQuery: The Missing Manual" by David Sawyer McFarland, page 184:


The jQuery toggle() function is like an on-off switch:






The hide() function is like the big red button in Dr.
 Strangelove:



The show() function is like the Genesis project from Star Trek:

Now I can look at the code: https://github.com/sawmac/js3e/blob/master/testbed/effects.html .


I spy:
          <p class="effect hid" title="show">show('#text')</p>
          <p class="effect vis" title="hide">hide('#text')</p>

as well as stuff like:

        
switch (action) {
case 'hide' :
target.hide();
break;
case 'show' :
target.show();
break;

and

var vis = $(targID).is(':visible');
$('.effect:contains('+targID+')').each(function() {
var $this = $(this);
if (vis) {
if ($this.hasClass('vis')) {
$this.fadeTo(.25,1);
}
if ($this.hasClass('hid')) {
$this.fadeTo(.25,.25);
}

No comments:

Post a Comment