其实我想做的当我悬停在第一张图片上时必须再次出现我想和你分享我的结构
<div class="tur-list-box">
<div class="tur-list-content">
<figure>
<img data-src="img/assets/tourlist-2.jpg" class="lazy" src="img/assets/placeholder.png" alt="tur sayfas?">
<a href="#" class="figure-overlay">
<p class="tour-price">
<span class="price-big">73,</span>
<span class="price-little">40</span>
<span class="price-unit">TL*</span>
<span class="price-block">‘den itibaren</span>
</p>
</a>
</figure><!-- tur resim-->
<div class="tur-details">
<h3><a href="#">Hafta Sonu Turlar?</a></h3>
<p>15 farkl? program</p>
<i class=" open-tur-toggle fa fa-chevron-down" aria-hidden="true"></i>
</div><!-- tur detay-->
</div><!-- tur list content-->
<div class="tur-list-toggle">
<ul class="list-unstyled">
<li><a href="#" data-img="http://cdn.anitur.com.tr/resimler/orta/2016-02/otel_buyuk-abant-oteli_vPYKBnet58y0itPrkpce.jpg">Kakava ( H?d?rellez ) ?enlikleri Alaçat? <i class="fa fa-chevron-right" aria-hidden="true"></i></a></li>
<li><a href="#" data-img="http://cdn.anitur.com.tr/resimler/orta/2016-10/otel_abant-palace-hotel_FTfyg8HYVB9lNeOUMA76.jpg">Ot Festivali Urla Enginar Festivali Turu <i class="fa fa-chevron-right" …Run Code Online (Sandbox Code Playgroud) 我正在努力提高我的 JavaScript 技能。使用 for 循环我想选择每个第二个元素(例如我想让它们加粗或斜体)。我知道我可以使用 CSS3 和nth-child选择器来做到这一点,但正如我所说,我正在努力提高我的 JS 技能,我想使用for循环和无foreach循环或其他 JS 循环类型来做到这一点。我是 JS 新手。
编辑:我想添加所有元素,但我只想选择每隔一个元素使它们加粗或斜体
var myList = document.getElementById('myList');
var addList = ["Python", "C", "C++", "Ruby", "PHP", "Javascript", "Go", "ASP", "R"];
for (var i = 0; i < addList.length; i++) {
var newLi = document.createElement("li");
newLi.innerHTML = addList[i];
myList.appendChild(newLi);
}Run Code Online (Sandbox Code Playgroud)
<ul id="myList"></ul>Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://ichef.bbci.co.uk/news/976/cpsprodpb/87D3/production/_84817743_beckhamfashion.jpg" alt="...">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="http://ichef.bbci.co.uk/news/976/cpsprodpb/9949/production/_84814293_dummy.jpg" alt="...">
<div class="carousel-caption">
...
</div>
</div>
...
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span …Run Code Online (Sandbox Code Playgroud)我想在列表打开时添加我选项左侧的图像,并且我正在使用功能完备的自动完成插件,我想添加一张图片来向您展示我想要做的事情.
我尝试添加内联css但没有任何改变
$(document).ready(function() {
$('.awesomplete').on('awesomplete-select', function() {
var $this = $(this),
$sibling = $this.next();
if ($sibling.attr('id') == 'mylist') {
setTimeout(function() {
var val = $this.find('input').val();
var dataLink = $sibling.find('option:contains("' + val + '")').data('link');
//console.log(dataLink);
location.href = dataLink;
}, 500);
}
});
});Run Code Online (Sandbox Code Playgroud)
.awesomplete>ul {
border-radius: .3em;
margin: .2em 0 0;
background: hsla(0, 0%, 100%, .9);
background: linear-gradient(to bottom right, white, hsla(0, 0%, 100%, .8));
border: 1px solid rgba(0, 0, 0, .3);
box-shadow: .05em .2em .6em rgba(0, 0, 0, …Run Code Online (Sandbox Code Playgroud)我有ajax页面,我正在使用jquery来获取我的内容,但只有一个页面正在使用我的ajax函数,但我有两个或两个以上的页面..我可以修复它吗?
$(document).ready(function() {
$('.lazy_content').each(function() {
data_url = $(this).attr("data-url");
data_id = $(this).attr("data-target-id");
$.ajax({
url: data_url,
type: "POST",
beforeSend: function() {
$("#" + data_id).html("");
},
success: function(data) {
$(data).each(function(index, el) {
$("#" + data_id).html(data);
});
}
})
});
});Run Code Online (Sandbox Code Playgroud)
<div class="lazy_content" data-url="http://www.anitur.com.tr/popup/test-1-comments" data-target-id="PostsArea">
<h4>COMMENTS</h4>
<div id="PostsArea"></div>
</div>
<div class="lazy_content" data-url="http://www.anitur.com.tr/popup/test-2-posts" data-target-id="CommentsArea">
<h4>POSTS</h4>
<div id="CommentsArea"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>Run Code Online (Sandbox Code Playgroud)
我在示例中有bootstrap轮播,因为你看到了我不想在html中添加指标我只想添加js来为每个轮播工作,我在互联网上找到了一个功能,它的工作非常好但是它的工作只是为了一个旋转木马
我有两个旋转木马#carousel-1,#carousel-2但我的功能工作只是为了#carousel-1.我知道如果我给同一个班级,我的问题将得到解决但旋转木马的ID和li.data-target指标必须相同.
如何carousel-indicators自动添加js以查看其指标?
var myCarousel = $("#carousel-1");
myCarousel.append("<ol class='carousel-indicators'></ol>");
var indicators = $(".carousel-indicators");
myCarousel.find(".carousel-inner").children(".item").each(function(index) {
(index === 0) ?
indicators.append("<li data-target='#carousel-1' data-slide-to='"+index+"' class='active'></li>") :
indicators.append("<li data-target='#carousel-1' data-slide-to='"+index+"'></li>");
});
$('.carousel').carousel();Run Code Online (Sandbox Code Playgroud)
.carousel{
margin:20px;
}Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<!-- Bootstrap …Run Code Online (Sandbox Code Playgroud)例如,在这个例子中我无法实现的东西是动态倒计时。
<span class="will-close">will be closed after : <strong>n</strong> seconds</span>
Run Code Online (Sandbox Code Playgroud)
正如你在上面看到的,我的时间很充裕,而且必须是倒计时
<span class="will-close">will be closed after : <strong>n</strong> seconds</span>
Run Code Online (Sandbox Code Playgroud)
$(function() {
setTimeout(function(e) {
$('#AniPopup').modal('show');
$(".will-close strong").html($("#AniPopup").attr("data-close"));
}, parseInt($('#AniPopup').attr('data-open')) * 1000);
setTimeout(function(e) {
$('#AniPopup').modal('hide');
}, parseInt($('#AniPopup').attr('data-close')) * 1000);
});Run Code Online (Sandbox Code Playgroud)
实际上它在第二次点击后打开,但我想第一次点击打开它我想它可以通过 jquery 事件实现。那么为什么我data-target用 jquery添加和数据切换?因为如果我data-title是,blank我将在新选项卡上打开我的链接,但如果我data-title是流行的,我将使用引导模式打开它,这就是我尝试使用 jquery 添加的原因。
$(document).on("click", "a[data-title]", function() {
var target = $(this).data("title");
var targetLink = $(this).attr("href");
if (target == "pop") {
$(this).attr({
'data-target': '#carouselModal',
'data-toggle': 'modal',
});
return false;
} else if (target == "blank") {
window.open(targetLink, '_blank');
return false;
} else {
}
});Run Code Online (Sandbox Code Playgroud)
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li …Run Code Online (Sandbox Code Playgroud)jquery中有多少参数,以下示例如何使用 this
我有两个选择框,如果我改变我的选择1的值,它们都是相同的另一个选择也一直在刺激,这是不应该这就是为什么我想要阻止这个我怎么能这样做?
$(document).ready(function() {
$(".person-1, .person-2").change(function() {
var val1 = parseInt($('.person-1').find(":selected").text()),
val2 = parseInt($('.person-2').find(":selected").text());
$(".addition-1").text(val1);
$(".addition-2").text(val2);
$(".addition").text(val1 + val2);
});
});Run Code Online (Sandbox Code Playgroud)
select {
width: 150px;
height: 40px;
}
.personBox {
background: #FFF;
width: 350px;
border: 1px solid #ccc;
padding: 10px;
float: left;
margin-right: 10px;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="personBox">
<h2>SELECT 1</h2>
<select class="person-1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<select class="person-2">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<p>Add 1: <span class="addition-1"></span></p>
<p>Add 2: <span class="addition-2"></span></p>
<p>Addition : …Run Code Online (Sandbox Code Playgroud)我正在使用一个插件来使我的div成为相同的例子:matchheight jquery插件并且我做了我想要的几乎,正如你在我的演示中看到的那样我的两个div是相同的但是我想做一点具体的:
我的.bdiv必须比.adiv 短,例如-15px或-10px ..我的问题是如何添加自定义-px?
$('.b').matchHeight({
target: $('.a')
});Run Code Online (Sandbox Code Playgroud)
.a,.b{
color:#fff;
padding:10px;
width:100px;
overflow:hidden;
float:left;
margin:5px;
}
.a{
background:red;
}
.b{
background:orange;
}Run Code Online (Sandbox Code Playgroud)
<div class="a">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu …Run Code Online (Sandbox Code Playgroud)