[英]JQuery cycle plugin - buttons
I am new to JQuery. 我是JQuery新手。 I am using JQuery cycle plugin to create a feature-box. 我正在使用JQuery cycle插件创建功能框。 the problem is that, I cannot figure out how to replace those 1,2,3,4 navigation to my "clickable" block buttons. 问题是,我不知道如何将那些1,2,3,4导航替换为我的“可单击”块按钮。
you can copy and paste all code to run it from this link: http://htmledit.squarefree.com 您可以从以下链接复制并粘贴所有代码以运行它: http : //htmledit.squarefree.com
Really appreciate if someone could help with this Many thanks 非常感谢有人可以帮助您,非常感谢
here is the code: 这是代码:
<!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" />
<title>test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
<script type="text/javascript" src="http://malsup.github.com/jquery.cycle.all.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var parentLI = $(this).parent('li');
var controller = $(this);
var $featured_content = $('#slideshow');
if ($featured_content.length) {
$('#slideshow').cycle({
timeout: 0,
speed: 500,
cleartypeNoBg: true,
cleartype: true,
pager: '#controller',
fx: 'fade',
});
}
$('.controller').click(function(event){
var parentLI = $(this).parent('li');
var controller = $(this);
// clickable
if (parentLI.hasClass('active')) {
return false;
}
$('.active').removeClass('active');
parentLI.addClass('active');
event.preventDefault();
});
});
</script>
<style type="text/css">
ol,ul{list-style:none;
}
#slideshow {
float:left;
width:962px;
height:308px;
border-bottom:#000 1px solid;
}
#slide {
float:left;
width:962px;
height:308px;
background: #FFF;
}
.imags1 {
background: green;
no-repeat;
height:290px;
margin:20px auto;
}
.imags2 {
background: red;
no-repeat;
height:290px;
margin:20px auto;
}
.imags3 {
background: yellow;
no-repeat;
height:290px;
margin:20px auto;
}
.imags4 {
background: purple;
no-repeat;
height:290px;
margin:20px auto;
}
#controller {
float:left;
width:962px;
height:179px;
border-top:1px solid #000;
}
.controller {
font-size:11px;
;
}
#controller h3 {
font-size:13px;
font-weight:bold;
}
#controller .active h1 {
color: #DD9A40;
}
#controller ul {
padding:0;
margin:0;
}
#controller li.active {
background: #6690c5;
}
#controller ul li {
float:left;
cursor: pointer;
}
#controller ul li .controller {
float:left;
width:191px;
height:160px;
padding: 20px 24px 0;
border-left:1px solid #000;
}
</style>
</head>
<body>
<div id="slideshow">
<div id="slide">
<div class="imags1"> </div> </div>
<div id="slide">
<div class="imags2"> </div> </div>
<div id="slide">
<div class="imags3"> </div> </div>
<div id="slide">
<div class="imags4"> </div> </div>
</div>
<div id="controller">
<ul>
<li class="active">
<div class="controller">
<h1>hello 1</h1>
</div>
</li>
<li >
<div class="controller">
<h1>hello 2</h1>
</div>
</li>
<li >
<div class="controller">
<h1>hello 3</h1>
</div>
</li>
<li>
<div class="controller">
<h1>Hello 4</h1>
</div>
</li>
</ul>
</div>
</div>
</body>
</html>
In your cycle plugin you have an option pager: '#controller', it tells the plugin to insert pagination/numbers in to your controller div. 在循环插件中,您有一个选项寻呼机:“#controller”,它告诉插件将分页/数字插入到控制器div中。 if you create another div (with style) in you page and change the pager: '#controller' option with your new div id then it will be placed in that div. 如果您在页面中创建另一个带有样式的div并使用新的div ID更改pager:'#controller'选项,则它将被放置在该div中。 Now it depends on you how you style your div and where you place it within your html. 现在,这取决于您如何设置div的样式以及将其放置在html中的位置。 For example you can create a new div for numbers 例如,您可以为数字创建一个新的div
<style>
#pagination{margin:auto;width:100px;height:15px;}
#pagination a{color:green;border:solid red 1px;}
</style>
<div id='pagination'></div>
Place your div where you want those numbers to be appeared and then change the cycle plugin 将div放置在您希望这些数字出现的位置,然后更改循环插件
pager: '#pagination'
See the change, you will get it. 看到更改,您将得到它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.