我需要减慢for循环的执行速度.我必须慢慢增加div的宽度.
到目前为止,我已经尝试delay(),setTimeout(),setInterval()但没有成功.他们似乎都表现得一样.
HTML
<body>
<h1>Hello</h1>
<div class="divclass">
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
jQuery的
$(document).ready(function () {
var width = $('.divclass').width();
for (var i = 0; i < 6; i++) {
width = width + 20;
$('.divclass').delay(2000);
$(".divclass").css("width", width);
};
});
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我我的错误所在.
提前致谢.
在Chrome和ff中,我的菜单有一个填充...我看到它在两个浏览器上都有效..但是当我在Safari中查看它时......填充不存在.
.jplnav li {
padding: 15px 0;
}
Run Code Online (Sandbox Code Playgroud)
我的下一个问题是......我想使用bxslider.我按照他们的说明如何安装它但它不能在我的最后工作.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="jquery.bxslider.min.js"></script>
<link href="/query.bxslider.css" rel="stylesheet" />
<title>My Slider</title>
</head>
<body>
<ul class="bxslider">
<li>Hi</li>
<li>Hello</li>
<li>Goodbye</li>
<li>Yes</li>
</ul>
<script>
$(document).ready(function(){
$('.bxslider').bxSlider();
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
未捕获的ReferenceError:jQuery未定义jquery.bxslider.min.js:10
未捕获的ReferenceError:$未定义index.html:19
无法加载资源文件://ajax.googleapis.com/ajax/libs/jquery/1.10. 2/jquery.min.js
有一点问题
点击后得到四个链接我想从外部html页面加载内容到一个叫做内容的div,它向下滑动并显示来自外部html页面的内容,但我想使用链接中的href来加载特定的div来自外部html页面的标签..我几乎就在那里错过了最后一部分..我似乎无法在我的jquery load语句中使用我的变量..
这就是我到目前为止所拥有的......
$("#services a").click(function(){
var href = $(this).attr("href");
console.log(href)
$('#content').slideToggle(function(){
$("#content").load("services.html" + href);
});
return false;
});
Run Code Online (Sandbox Code Playgroud)
如果有人能指出我如何在选择不同的链接时滑回内容div,然后显示该链接的内容..会很棒..
多谢你们..
我有以下html ....
<div id="test">
<div>
<img /><img /><img />
</div>
<div>
<img /><img /><img />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$('#clickto').click(function(){
$('<h1>hi</h1>').appendTo('#test div:nth-child(1)');
$('<h1>hi</h1>').appendTo('#test div:nth-child(2)');
});
Run Code Online (Sandbox Code Playgroud)
因为我追加了两次,我必须添加相同的元素.我认为有一个简单的方法.
我试过这个,但只附加一个div:
$('<h1>hi</h1>').appendTo('#test div');
Run Code Online (Sandbox Code Playgroud) 我正在使用此代码:http: //jsfiddle.net/fGHmF/2/
现在我想为每个IMG id添加"size"这个词.例如:
<img src='images/size1.png' alt='img1' id='size1' />
<img src='images/size2.png' alt='img2' id='size2' />
<img src='images/size3.png' alt='img3' id='size3' />
<img src='images/size4.png' alt='img4' id='size4' />
Run Code Online (Sandbox Code Playgroud)
我需要在java脚本中更改什么?
HTML片段:
<li class = "li_image"></li>
Run Code Online (Sandbox Code Playgroud)
CSS片段:
li_img {
width:28px;
height:32px;
background:url(https://ssl.gstatic.com/gb/images/v1_90902864.png) 10 15;
}
Run Code Online (Sandbox Code Playgroud)
知道为什么这不起作用吗?此列表项甚至没有出现在列表中.
我有一组超链接都链接到其他页面和/或网站,每个链接都有一个类,从1开始逐渐递增,我只希望从'1'级到现在的链接是活动的,但是链接自己保持可见.
<div>
<a href="http://google.com" class="link 1">LINK 1</a>
<a href="http://google.com" class="link 2">LINK 2</a>
<a href="http://google.com" class="link 3">LINK 3</a>
<a href="http://google.com" class="link 4">LINK 4</a>
</div>
Run Code Online (Sandbox Code Playgroud)
我试过这个,但它不起作用.
var d = new Date(),
day = d.getDate(),
number = $('a.link').attr("class").match(/\d+/);
if (number > day) {
$("a.link").attr("href", "#")
} else {}
Run Code Online (Sandbox Code Playgroud)
我正在尝试更改href而不是禁用链接,以便人们无法通过查看页面源代码来查看地址.
我正在努力减少我拥有的JS数量,而且我不确定为什么我不允许按照我正在尝试的方式去做.这只是代码,用于图像上的一些鼠标悬停/鼠标悬停功能:
$(document).ready(function() {
$("#social_btn_1").on('mouseover', function(){
$(this).attr('src', 'images/social_1_dwn.png');
})
$("#social_btn_1").on('mouseout', function(){
$(this).attr('src', 'images/social_1.png');
})
$("#social_btn_2").on('mouseover', function(){
$(this).attr('src', 'images/social_2_dwn.png');
})
$("#social_btn_2").on('mouseout', function(){
$(this).attr('src', 'images/social_2.png');
})
$("#social_btn_3").on('mouseover', function(){
$(this).attr('src', 'images/social_3_dwn.png');
})
$("#social_btn_3").on('mouseout', function(){
$(this).attr('src', 'images/social_3.png');
})
$("#social_btn_4").on('mouseover', function(){
$(this).attr('src', 'images/social_4_dwn.png');
})
$("#social_btn_4").on('mouseout', function(){
$(this).attr('src', 'images/social_4.png');
})
});
Run Code Online (Sandbox Code Playgroud)
而我正试图通过这样做来缩短:
$(document).ready(function() {
for (var i = 1; i < 5; i++) {
$("#social_btn_"+ i).on('mouseover', function(){
$("#social_btn_"+ i).attr('src', 'images/social_'+ i +'_dwn.png');
})
$("#social_btn_"+ i).on('mouseout', function(){
$("#social_btn_"+ i).attr('src', 'images/social_'+ i +'.png');
})
}
});
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释为什么这不起作用,巩固我的代码的最佳方法是什么?(顺便说一下,我知道你可以用CSS3做这个东西,但我需要使用JQuery).谢谢.
我的页面上有一些图像,但它们都是相同的图像.我想知道如何用jQuery改变它们.以下是我目前设置的内容.
我有每个图像与ID等image-1,image-2等,并改变它们我使用
$("#image-1").attr({src:"..."});
$("#image-2").attr({src:"..."});
Run Code Online (Sandbox Code Playgroud)
有没有办法我可以设置我的ID myTag,然后为每个具有该ID的图像更改图像src?因为如果我在现在的方法中这样做,它只会改变带有该id的第一个图像.
我有这样的HTML代码:
<tr>
<th colspan="2" style="padding: 10px; font-size: 11px; background: #eee; border: 1px solid white" align="left">
Some Text Here
</th>
</tr>
Run Code Online (Sandbox Code Playgroud)
我将其存储在字符串中,如下所示:
string gtr =
@"<tr>
<th colspan=""2"" style=""padding: 10px; font-size: 11px; background: #eee; border: 1px solid white"" align=""left"">
Some Text Here
</th>
</tr>";
Run Code Online (Sandbox Code Playgroud)
但当我调试它显示字符串时像这样:
<tr>
<th colspan=\"2\" style=\"padding: 10px; font-size: 11px; background: #eee; border: 1px solid white\" align=\"left\">
Some Text Here
</th>
</tr>
Run Code Online (Sandbox Code Playgroud)
它显示转义序列字符.
它试图像这样删除它们
gtr = gtr.Replace(@"\","");
Run Code Online (Sandbox Code Playgroud)
并使用所有其他可能的方法
但这不起作用它总是显示字符串gtr与转义序列字符.
如何在没有Escape Sequence Character的情况下实现字符串,并且只提供清晰的HTML代码.
我只使用ASP.NET和C#而不是使用MVC,这是一个静态内容.