javascript - Add title in addition to data description in JS file -


i working on jquery gallery , each image has data description. want add title above each data description. how can this? cannot figure out. thanks. suspecting variables need changed in code snippet posted below.

var $loader = $rggallery.find('div.rg-loading').show();                  $items.removeclass('selected');                 $item.addclass('selected');                  var $thumb      = $item.find('img'),                     largesrc    = $thumb.data('large'),                     title       = $thumb.data('description');                   $('<img/>').load( function() {                      $rggallery.find('div.rg-image').empty().append('<img src="' + largesrc + '"/>');                      if( title )                         $rggallery.find('div.rg-caption').show().children('p').empty().text( title );                      $loader.hide();                      if( mode === 'carousel' ) {                         $escarousel.elastislide( 'reload' );                         $escarousel.elastislide( 'setcurrent', current );                     }                      anim    = false;                  }).attr( 'src', largesrc );              };          return { init : init };      })();      gallery.init(); }); 

here's html code in js fiddle file: jsfiddle.net/amw312/tq86nv7z/62/

i think should set on correct path. of course, not know if want special formatting. see in example, added data-title attribute. put title inside description block. can seperate out (remember make elem available. reduced typing creating local elem var).

        var $thumb      = $item.find('img'),             largesrc    = $thumb.data('large'),             description = $thumb.data('description');             title       = $thumb.data('title');           $('<img/>').load( function() {              $rggallery.find('div.rg-image').empty().append('<img src="' + largesrc + '"/>');              if( description ){                  var elem =  $rggallery.find('div.rg-caption').show().children('p')                   elem.empty().text( description );                   if(title)                      elem.prepend(title + "<br />");              }              $loader.hide(); 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -