jQuery가 Magento에서 작동하지 않습니다. 나는 시간 카운트 다운을 보여주고 싶다. 작동하지 않습니다. 여기 내 site link입니다. 여기에 두 번째 id가 있으며 시차 값이 있습니다. 값을 인쇄하지만 JavaScript는 일일 거래와 같이 시간 수를 표시하지 않습니다. jquery가 magento에서 작동하지 않습니다.
<script type="text/javascript">
function updateClock(id)
{
var pid = id;
var currentSeconds1 = jQuery("#hello" + pid).val();
mySeconds = currentSeconds1 - 1;
jQuery("#second" + pid).val(mySeconds);
alert(currentSeconds1);
if(mySeconds == 0){
location.reload();
}
else{
var currentdays = Math.floor(mySeconds/86400);
var remainiday = mySeconds%86400;
var currentHours = Math.floor(remainiday/3600);
var myHours = remainiday%3600;
var currentMinutes = Math.floor(myHours/60);
var currentSeconds = myHours%60;
// Compose the string for display
currentHours = (currentHours < 10? '0' : '') + currentHours;
currentMinutes = (currentMinutes < 10? '0' : '') + currentMinutes;
currentSeconds = (currentSeconds < 10? '0' : '') + currentSeconds;
var currentTimeString = currentdays + ' Days ' + currentHours + "h : " + currentMinutes + "m : " + currentSeconds +"s";
var t = jQuery("#clock" + pid).html(currentTimeString);
}
}
</script>
그리고 젠토 코드 당신이뿐만 아니라
Prototype.js
을 사용하고
jquery noconflict
을 사용하지 않는 것 같다
<?php foreach ($productCollection->getItems() as $_product): ?>
<div class="time-left" style="font-weight: bold; color:#ff0000; font-size: 13px;">Time Left :
<span id="cl"></span>
<?php
$date1 =date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
$date2 = date("Y-m-d 23:59:59", strtotime($_product->getSpecialToDate()));
$timeFirst = strtotime($date1);
$timeSecond = strtotime($date2);
echo $differenceInSeconds = $timeSecond - $timeFirst;
?>
<input type="button" id="sec" value="<?php echo $differenceInSeconds ?>" /></div>
<div class="product-image">
<a href="%3C?php%20echo%20$_product-%3EgetProductUrl()%20?%3E"
title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
<img src="%3C?php%20echo%20$this-%3Ehelper('catalog/image')-%3Einit($_product,%20'small_image')-%3Eresize(161,123);%20?%3E"
width="161" height="123" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
</a>
</div>
<span id="clock<?php echo $_product->getId() ?>"></span>
<?php
$date1 =date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
$date2 = date("Y-m-d 23:59", strtotime($_product->getSpecialToDate()));
$timeFirst = strtotime($date1);
$timeSecond = strtotime($date2);
$differenceInSeconds = $timeSecond - $timeFirst;
?>
<form>
<input type="hidden" id="hello" value="12" />
<input type="hidden" id="second<?php echo $_product->getId() ?>" value="<?php echo $differenceInSeconds ?>" />
</form>
<div class="product-info">
<h3 class="product-name">
<a href="%3C?php%20echo%20$_product-%3EgetProductUrl()%20?%3E" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
<?php echo $this->htmlEscape($_product->getName()) ?>
</a>
</h3>
</div>
<?php //if($isShowDescription == 1):?>
<?php endforeach?>
updateClock 함수 앞에 jQuery.noConflict()를 사용하십시오. –
두 가지 버전의 jquery로드가 없어야합니다. 제품 슬라이더에 의해 도입 된 버전을 제거해야합니다. – RichTea