2013-03-19 55 views
0

我似乎無法得到jquery時間插件的工作。我如何安裝jquery時間插件

這裏是我的代碼

<html> 
<head> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
<script src="jquery.timeago.js"></script> 
</head> 

<body> 
<abbr class="timeago" title="19 March 2013 04:51:33 PM"></abbr> 
</body> 
</html> 

它似乎沒有工作...

回答

2

,你必須啓動插件 這樣

jQuery(document).ready(function($){ 
$("abbr.timeago").timeago() 

}); 

最終代碼會是這樣

<html> 
<head> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
<script src="jquery.timeago.js"></script> 
</head> 

<body> 
<abbr class="timeago" title="19 March 2013 04:51:33 PM"></abbr> 

    <script> 
    jQuery(document).ready(function($){ 
    $("abbr.timeago").timeago() 

    }); 
    </script> 

</body> 
</html> 

希望這有助於

2

添加到您的網頁:

jQuery(document).ready(function() { 
    jQuery("abbr.timeago").timeago(); 
}); 

請務必遵循的說明http://timeago.yarp.com/(見如何?部分)