Javascript 引导转盘导航不工作
不久前,我正在开发bootstrap carousel,它分别表示基于办公室和房屋的属性缩略图 整个功能正常,但转盘导航不工作 这里是HTML代码Javascript 引导转盘导航不工作,javascript,jquery,twitter-bootstrap,carousel,Javascript,Jquery,Twitter Bootstrap,Carousel,不久前,我正在开发bootstrap carousel,它分别表示基于办公室和房屋的属性缩略图 整个功能正常,但转盘导航不工作 这里是HTML代码 <div class="container-fluid"> <div class="row-fluid"> <div class="span12" id="work_hider"> <div class="page-header"> <h2 class="pull-lef
<div class="container-fluid">
<div class="row-fluid">
<div class="span12" id="work_hider">
<div class="page-header">
<h2 class="pull-left"><?php if($this->lang->line('work') != '') { echo stripslashes($this->lang->line('work')); } else echo "Work"; ?></h2>
<h3 class="pull-right" id="geolocate_work"></h3>
<script>
$.getJSON("https://freegeoip.net/json/", function(data) {
var country = data.country_name;
var city = data.city;
$("#geolocate_work").html("<a href='property?city="+city+"'><?php if($this->lang->line('see_all') != '') { echo stripslashes($this->lang->line('see_all')); } else echo "See All"; ?></a>");
jQuery.ajax({
type:'POST',
url:'<?php echo base_url("site/landing/get_work_places"); ?>',
data:{ city_name:city},
dataType: 'json',
success:function(data)
{
var ParsedObject = JSON.stringify(data);
var json = $.parseJSON(ParsedObject);
if (json=="")
{
$('#work_hider').hide();
}else
{
$.each(json, function(key, data)
{
// All the variables from the database containing the post data.
var product_id=data.product_id;
var product_name=data.product_title;
var product_image=data.product_image;
var work_price = data.price_perhour;
var work_address = data.address;
$("#work-carousel").append('<li class="span3"><div class="thumbnail"><a href="<?php echo base_url('rental'); ?>/'+product_id+'"><img src="'+product_image+'" alt=""></a></div><div class="caption"><h2>'+work_price+'</h2></div><div class="caption"><h4>'+product_name+'</h4> <p>'+work_address+'</p></div></li>');
});
for (i = 0; i <= 1; i++) {
$('.span3').slice(i * 4, (i + 1) * 4).wrapAll('<div class="item"><ul id="work_property">');
}
}
}
});
});
</script>
</div>
<div class="work_carousel slide" id="myCarousel">
<div class="carousel-inner" id="work-carousel">
<div class="item active" style="height: 100% !important;">
<ul class="thumbnails" id="work_property">
</ul>
</div>
</div>
<div class="control-box" style="margin-bottom: 2em;">
<a data-slide="prev" href="#myCarousel" class="carousel-control left">‹</a>
<a data-slide="next" href="#myCarousel" class="carousel-control right">›</a>
</div>
</div>
</div>
</div>
</div>
$.getJSON(“https://freegeoip.net/json/,函数(数据){
var country=data.country\u name;
var city=data.city;
$(“#地理定位工作”).html(“”);
jQuery.ajax({
类型:'POST',
url:“”,
数据:{城市名称:城市},
数据类型:“json”,
成功:功能(数据)
{
var ParsedObject=JSON.stringify(数据);
var json=$.parseJSON(ParsedObject);
如果(json==“”)
{
$(“#工作隐藏”).hide();
}否则
{
$.each(json、函数(键、数据)
{
//包含post数据的数据库中的所有变量。
var product_id=data.product_id;
var product_name=data.product_title;
var product_image=data.product_image;
var工时价格=每小时数据价格;
var work_address=data.address;
$(“#工作转盘”).append(“”+工作价格+”+产品名称+”“+工作地址+”);
});
对于(i=0;i=2){
$('#work_property').attr(“id”)=“newid”;
}
});
我搜索了很多地方,但无法修复。有人给我提建议吗?提前谢谢!看起来像:$('work'u property')。attr(“id”)=“newid”;正在将值分配给错误的元素。那么,我如何修复它?明白了@Gerard先生。但是我如何才能在运行两张幻灯片后自动阻止幻灯片?您有什么建议吗?您所说的是旋转木马导航不起作用。您能说得更具体一些吗?代码是否中断?功能是否不正确?获取一个链接到一个工作示例,因为此处缺少CSS,或者使用片段自己创建一个。在此carousal代码中,我将通过更改id在两张幻灯片之后停止幻灯片。它可以工作,但也会影响导航:(
<script>
var totalItems = $('.item').length;
var currentIndex = $('div.active').index() + 1;
$('.num').html(''+currentIndex+'/'+totalItems+'');
$('.work_carousel').carousel({
interval: 2000
});
$('.work_carousel').on('slide.bs.carousel', function() {
currentIndex = $('div.active').index() + 1;
if(currentIndex >= 2){
$('#work_property').attr("id")="newid";
}
});
</script>