Skip to content

Commit

Permalink
Fix issue on Chrome, factorised body selectors
Browse files Browse the repository at this point in the history
Closed #11
  • Loading branch information
nico3333fr committed Jun 22, 2016
1 parent 40ca46d commit 20f1272
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions jquery-accessible-hide-show-aria.js
Expand Up @@ -13,6 +13,7 @@ $(document).ready(function(){
attr_hidden = 'data-hidden',
$expandmore = $('.js-expandmore'),
$to_expand = $('.js-to_expand'),
$body = $('body'),
delay = 1500;


Expand Down Expand Up @@ -55,7 +56,7 @@ $(document).ready(function(){
}


$( 'body' ).on( 'click', '.js-expandmore-button', function( event ) {
$body.on( 'click', '.js-expandmore-button', function( event ) {
var $this = $(this),
$destination = $( '#' + $this.attr(attr_control) );

Expand All @@ -72,12 +73,12 @@ $(document).ready(function(){

});

$( 'body' ).on( 'click keydown', '.js-expandmore', function( event ) {
$body.on( 'click keydown', '.js-expandmore', function( event ) {
var $this = $(this),
$target = $(event.target),
$button_in = $this.find( '.js-expandmore-button' );

if ( !$target.is($button_in) ) {
if ( !$target.is($button_in) && !$target.closest($button_in).length ) {

if ( event.type == 'click' ){
$button_in.trigger('click');
Expand Down

0 comments on commit 20f1272

Please sign in to comment.