jQuery无法正常工作 [英] Jquery is not working properly
本文介绍了jQuery无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么新闻没有上升?
高度和其他选项运行正常,但方向有问题.请检查他/她是否知道.
这是完整的代码:
why news is not moving up??
height and other options are running fine but direction is having problem.someone please check if he/she knows.
Here is the full code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewNews.aspx.cs" Inherits="TestPage" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html>
<head runat="server">
<title>News Module</title>
<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.vticker.js" type="text/javascript"></script>
<%--<link href="Styles/NewsStyle.css" rel="stylesheet" type="text/css" />--%>
<script type="text/javascript">
$(document).ready(function () {
$(function () {
$('.MoveNews').vTicker({
speed: 500,
pause: 300,
showItems: 3,
animation: 'fade',
mousePause: true,
height: 80,
direction: 'else'
});
});
});
</script>
<style type="text/css">
#Newsform
{
height: 361px;
}
</style>
</head>
<body>
<form id="Newsform" runat="server">
<div>
<table>
<tr>
</tr>
<tr>
<td>
<asp:Repeater ID="RptNews" runat="server">
<ItemTemplate>
<h2></h2>
<li class="MoveNews"><%# Eval("Title")%><br />
Created Date:<%# Eval("StartDate")%><br /><Br /><%# Eval("Content")%><asp:HyperLink ID="MoreLink" runat="server" Text="More" NavigateUrl='<%# Eval("URL")%>'></asp:HyperLink>
</li>
</ItemTemplate>
</asp:Repeater>
</table>
</div>
</form>
</body>
</html>
这是.js文件:
here is the .js file:
/*
* vertical news ticker
* Tadas Juozapaitis ( kasp3rito [eta] gmail (dot) com )
* http://www.jugbit.com/jquery-vticker-vertical-news-ticker/
*/
(function($){
$.fn.vTicker = function(options) {
var defaults = {
speed: 700,
pause: 4000,
showItems: 3,
animation: '',
mousePause: true,
isPaused: false,
direction: 'up',
height: 0
};
var options = $.extend(defaults, options);
moveUp = function(obj2, height, options){
if(options.isPaused)
return;
var obj = obj2.children('ul');
var clone = obj.children('li:first').clone(true);
if(options.height > 0)
{
height = obj.children('li:first').height();
}
obj.animate({top: '-=' + height + 'px'}, options.speed, function() {
$(this).children('li:first').remove();
$(this).css('top', '0px');
});
if(options.animation == 'fade')
{
obj.children('li:first').fadeOut(options.speed);
if(options.height == 0)
{
obj.children('li:eq(' + options.showItems + ')').hide().fadeIn(options.speed).show();
}
}
clone.appendTo(obj);
};
moveDown = function(obj2, height, options){
if(options.isPaused)
return;
var obj = obj2.children('ul');
var clone = obj.children('li:last').clone(true);
if(options.height > 0)
{
height = obj.children('li:first').height();
}
obj.css('top', '-' + height + 'px')
.prepend(clone);
obj.animate({top: 0}, options.speed, function() {
$(this).children('li:last').remove();
});
if(options.animation == 'fade')
{
if(options.height == 0)
{
obj.children('li:eq(' + options.showItems + ')').fadeOut(options.speed);
}
obj.children('li:first').hide().fadeIn(options.speed).show();
}
};
return this.each(function() {
var obj = $(this);
var maxHeight = 0;
obj.css({overflow: 'hidden', position: 'relative'})
.children('ul').css({position: 'absolute', margin: 0, padding: 0})
.children('li').css({margin: 0, padding: 0});
if(options.height == 0)
{
obj.children('ul').children('li').each(function(){
if($(this).height() > maxHeight)
{
maxHeight = $(this).height();
}
});
obj.children('ul').children('li').each(function(){
$(this).height(maxHeight);
});
obj.height(maxHeight * options.showItems);
}
else
{
obj.height(options.height);
}
var interval = setInterval(function(){
if(options.direction == 'up')
{
moveUp(obj, maxHeight, options);
}
else
{
moveDown(obj, maxHeight, options);
}
}, options.pause);
if(options.mousePause)
{
obj.bind("mouseenter",function(){
options.isPaused = true;
}).bind("mouseleave",function(){
options.isPaused = false;
});
}
});
};
})(jQuery);
推荐答案
(文档).ready(函数(){
(document).ready(function () {
(函数(){
(' .MoveNews').vTicker({ 速度: 500 , 暂停: 300 , showItems: 3 , 动画:' 淡化', mousePause: true , 高度: 80 , 方向:' 其他' }); }); }); < / 脚本 > < 样式 =" text/css" 新闻形式 { 高度 : 361px; } </ 样式 > < /head > < 正文 > < 表单 =" Newsform" runat >服务器" > < div > < 表 > < tr > < /tr > < tr > < td > < asp:Repeater ID =" runat 服务器" < ItemTemplate > < h2 > < /h2 > < li =" MoveNews" <%#Eval( )< > 创建日期:<%#Eval(" )%> < br / > < Br > " 内容")< =" runat 服务器" 文本 =" 更多" NavigateUrl =' <%#Eval( URL")> < /asp:HyperLink > < /li > < /ItemTemplate > < /asp:Repeater > < /table > < /div > < /form > < /body > < /html >
('.MoveNews').vTicker({ speed: 500, pause: 300, showItems: 3, animation: 'fade', mousePause: true, height: 80, direction: 'else' }); }); }); </script> <style type="text/css"> #Newsform { height: 361px; } </style> </head> <body> <form id="Newsform" runat="server"> <div> <table> <tr> </tr> <tr> <td> <asp:Repeater ID="RptNews" runat="server"> <ItemTemplate> <h2></h2> <li class="MoveNews"><%# Eval("Title")%><br /> Created Date:<%# Eval("StartDate")%><br /><Br /><%# Eval("Content")%><asp:HyperLink ID="MoreLink" runat="server" Text="More" NavigateUrl='<%# Eval("URL")%>'></asp:HyperLink> </li> </ItemTemplate> </asp:Repeater> </table> </div> </form> </body> </html>
这是.js文件:
here is the .js file:
/*
* vertical news ticker
* Tadas Juozapaitis ( kasp3rito [eta] gmail (dot) com )
* http://www.jugbit.com/jquery-vticker-vertical-news-ticker/
*/
(function(
这篇关于jQuery无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文