php - Display an image alt or title below the image and in h1 html tag -


i've got image carousel in site. want display image alt tag or title below image when mover over. @ same time want display same name in h1 tag.

the code in php , magento implementation. know simple trick. tried codes using jquery after, append , replacewith functions. these functions working. couldn't display alt or title name.

php code:

<ul id="mycarousel" class="jcarousel-skin-tango alt"> <?php  // products  if(!isset($catid)) $catid = 10; // set classic collection if empty; $_category = mage::getmodel('catalog/category')->load($catid); $products = mage::getmodel('catalog/product')->getcollection()     ->addattributetofilter('status', 1)//enabled         ->addcategoryfilter($_category); foreach($products $index=>$prod): $product = mage::getmodel('catalog/product')->load($prod->getid()); echo '<li style="border: none;"> <a class="thumbactimg1" href="'.$product->getproducturl().'" data-rel="'.(string)mage::helper('catalog/image')->init($product, 'small_image')->keepframe(false)->resize($_resize, $_resize).'" alt="'. $product->getname() .'"> <div class="thumbactimg2"> <img src="'.$product->getthumbnailurl(80, 80).'" alt="'. $product->getname() .'" />         </div> </a> </li>'; endforeach; ?> </ul> 

jquery code:

jquery(this,'img.thumbactimg2').after('<div class="pname"><?php echo     $product->getname()?></div>'); jquery('#pro_name h1').replacewith('<h1><?php echo $product->getname()?></h1>'); 

right now, used php echo in order display name. displaying current page product name instead of mover on image name.

could me out please.

hi,

the php-code evaluated once, when site generated. <h1><?php echo $product->getname()?></h1> same text.

you have rewrite/get current information image, when it's cycled (if understand you). here may work you:

//insert code, carousel triggered //get alt attribute image , replace h1 content jquery('#pro_name h1').html(jquery('img.thumbactimg2').attr('alt')); 

i hope you're looking for, problem isn't descripted briefly.

greetings mat


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -