<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<div class="container">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
<script type="text/javascript">
$('body').append($('.container').html());
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<div class="container">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
<script type="text/javascript">
$('body').append($('.container').html());
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(21)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<style type="text/css">
.red{
color: red;
}
</style>
</head>
<body>
<ul>
<li>1</li>
<li>2</li>
<li id="three">3</li>
<li>4</li>
<li>5</li>
</ul>
<script type="text/javascript">
$(function(){
$('li[id!="three"]').addClass('red');
});
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<style type="text/css">
.red{
color: red;
}
</style>
</head>
<body>
<ul>
<li>1</li>
<li>2</li>
<li id="three">3</li>
<li>4</li>
<li>5</li>
</ul>
<script type="text/javascript">
$(function(){
$('li[id!="three"]').addClass('red');
});
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(2)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<h2>title</h2>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
小於<input id="input">會被刪掉
<button id="btn">按我</button>
<script type="text/javascript">
$('#btn').on('click',function(){
var input=$('#input').val()-1;
$('li:lt('+input+')').fadeOut(800).queue(function(){
$(this).remove();
})
});
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(3)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<h2>title</h2>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
小於<input id="input">會被刪掉
<button id="btn">按我</button>
<script type="text/javascript">
$('#btn').on('click',function(){
var input=$('#input').val()-1;
$('li:lt('+input+')').fadeOut(800).queue(function(){
$(this).remove();
})
});
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<h2>降下來</h2>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
<script type="text/javascript">
$(function(){
$('h2').hide().slideDown();
$('li').hide().each(function(index){
$(this).delay(index*500).fadeIn(500);
});
});
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(3)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<h2>降下來</h2>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
<script type="text/javascript">
$(function(){
$('h2').hide().slideDown();
$('li').hide().each(function(index){
$(this).delay(index*500).fadeIn(500);
});
});
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.out{
width: 500px;
height: 500px;
background-color: Coral;
}
.middle{
width: 300px;
height: 300px;
background-color: Wheat;
margin:auto;
transform: translateY(calc(250px - 150px));
}
.inside{
width: 100px;
height: 100px;
background-color: PaleGoldenRod;
margin: auto;
transform: translateY(calc(150px - 50px));
}
</style>
</head>
<body>
<div class="out">
<div class="middle">
<div class="inside"></div>
</div>
</div>
<script type="text/javascript">
var i =0;
document.getElementsByClassName('inside')[0].onclick=function(){
i++;
this.appendChild(document.createTextNode('按到我了'+i));
}
document.getElementsByClassName('middle')[0].onclick=function(){
i++;
this.appendChild(document.createTextNode('按到我了'+i));
}
document.getElementsByClassName('out')[0].onclick=function(){
i++;
this.appendChild(document.createTextNode('按到我了'+i));
}
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.out{
width: 500px;
height: 500px;
background-color: Coral;
}
.middle{
width: 300px;
height: 300px;
background-color: Wheat;
margin:auto;
transform: translateY(calc(250px - 150px));
}
.inside{
width: 100px;
height: 100px;
background-color: PaleGoldenRod;
margin: auto;
transform: translateY(calc(150px - 50px));
}
</style>
</head>
<body>
<div class="out">
<div class="middle">
<div class="inside"></div>
</div>
</div>
<script type="text/javascript">
var i =0;
document.getElementsByClassName('inside')[0].onclick=function(){
i++;
this.appendChild(document.createTextNode('按到我了'+i));
}
document.getElementsByClassName('middle')[0].onclick=function(){
i++;
this.appendChild(document.createTextNode('按到我了'+i));
}
document.getElementsByClassName('out')[0].onclick=function(){
i++;
this.appendChild(document.createTextNode('按到我了'+i));
}
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(2)