<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
var person={
name:'jerry',
height:'177'
};
document.write(person.hasOwnProperty('name'));
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
var person={
name:'jerry',
height:'177'
};
document.write(person.hasOwnProperty('name'));
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(10)
<!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">
*{
margin: 0;
padding: 0;
list-style:none;
}
body{
height: 100vh;
position: relative;
padding: 20px;
box-sizing: border-box;
}
.newBox{
position: fixed;
border: 1px solid #aaa;
text-align: center;
padding: 10px;
box-sizing: border-box;
}
</style>
</head>
<body>
<button id="btn">按我</button>
<div id="lightbox">
<img src="https://api.fnkr.net/testimg/100x100/a00/FFF/?text=LightBox">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis, pariatur! Alias aspernatur, animi adipisci amet similique ipsam, incidunt laborum totam!</p>
</div>
<script type="text/javascript">
var myFunction=(function(){
var $window = $(window);
var $newBox=$('<div class="newBox"></div>');
var $newContent=$('<div class="newBoxContent"></div>');
var $newClose=$('<button class="newBoxClose">關掉</button>');
$newBox.append($newContent,$newClose);
$newClose.on('click',function(){
myFunction.close();
});
return{
center:function(){
var dtop = Math.max($window.height()-$newBox.outerHeight(),0)/2;
var dleft = Math.max($window.width()-$newBox.outerWidth(),0)/2;
$newBox.css({
top:dtop+$window.scrollTop(),
left:dleft+$window.scrollLeft()
});
},
open:function(data){
$newContent.empty().append(data.content);
$newBox.css({
width:data.width || 'auto',
height:data.height || 'auto'
}).appendTo('body');
myFunction.center();
$window.on('resize',myFunction.center);
},
close:function(){
$newContent.empty();
$newBox.detach();
$window.off('resize',myFunction.center);
}
}
}());
</script>
<script type="text/javascript">
(function(){
var $newContent=$('#lightbox').detach();
$('#btn').on('click',function(){
myFunction.open({
content:$newContent,
width:340,
height:300
})
});
}());
</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">
*{
margin: 0;
padding: 0;
list-style:none;
}
body{
height: 100vh;
position: relative;
padding: 20px;
box-sizing: border-box;
}
.newBox{
position: fixed;
border: 1px solid #aaa;
text-align: center;
padding: 10px;
box-sizing: border-box;
}
</style>
</head>
<body>
<button id="btn">按我</button>
<div id="lightbox">
<img src="https://api.fnkr.net/testimg/100x100/a00/FFF/?text=LightBox">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis, pariatur! Alias aspernatur, animi adipisci amet similique ipsam, incidunt laborum totam!</p>
</div>
<script type="text/javascript">
var myFunction=(function(){
var $window = $(window);
var $newBox=$('<div class="newBox"></div>');
var $newContent=$('<div class="newBoxContent"></div>');
var $newClose=$('<button class="newBoxClose">關掉</button>');
$newBox.append($newContent,$newClose);
$newClose.on('click',function(){
myFunction.close();
});
return{
center:function(){
var dtop = Math.max($window.height()-$newBox.outerHeight(),0)/2;
var dleft = Math.max($window.width()-$newBox.outerWidth(),0)/2;
$newBox.css({
top:dtop+$window.scrollTop(),
left:dleft+$window.scrollLeft()
});
},
open:function(data){
$newContent.empty().append(data.content);
$newBox.css({
width:data.width || 'auto',
height:data.height || 'auto'
}).appendTo('body');
myFunction.center();
$window.on('resize',myFunction.center);
},
close:function(){
$newContent.empty();
$newBox.detach();
$window.off('resize',myFunction.center);
}
}
}());
</script>
<script type="text/javascript">
(function(){
var $newContent=$('#lightbox').detach();
$('#btn').on('click',function(){
myFunction.open({
content:$newContent,
width:340,
height:300
})
});
}());
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(87)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
span{
color: #a00;
}
</style>
</head>
<body>
<h2>greet1:<span id="greet1"></span></h2>
<h2>greet1.language:<span id="greet1_lan"></span></h2>
<h2>greet2:<span id="greet2"></span></h2>
<h2>greet3:<span id="greet3"></span></h2>
<h2>greet4:<span id="greet4"></span></h2>
<script type="text/javascript">
function greet1(name){
document.getElementById('greet1').innerHTML='Hi '+name;
}
greet1('john');
greet1.language='English';
document.getElementById('greet1_lan').innerHTML=greet1.language;
var greet2=function(name){
document.getElementById('greet2').innerHTML='Hi '+name;
}
greet2('mike');
var greet3=function(name){
document.getElementById('greet3').innerHTML='Hi '+name;
}('peter');
(function(name){
document.getElementById('greet4').innerHTML='Hi '+name;
}('frank'));
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
span{
color: #a00;
}
</style>
</head>
<body>
<h2>greet1:<span id="greet1"></span></h2>
<h2>greet1.language:<span id="greet1_lan"></span></h2>
<h2>greet2:<span id="greet2"></span></h2>
<h2>greet3:<span id="greet3"></span></h2>
<h2>greet4:<span id="greet4"></span></h2>
<script type="text/javascript">
function greet1(name){
document.getElementById('greet1').innerHTML='Hi '+name;
}
greet1('john');
greet1.language='English';
document.getElementById('greet1_lan').innerHTML=greet1.language;
var greet2=function(name){
document.getElementById('greet2').innerHTML='Hi '+name;
}
greet2('mike');
var greet3=function(name){
document.getElementById('greet3').innerHTML='Hi '+name;
}('peter');
(function(name){
document.getElementById('greet4').innerHTML='Hi '+name;
}('frank'));
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(144)
Jerry 發表在 痞客邦 留言(0) 人氣(29)
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">
.tab-list li{
display: inline-block;
}
.tab-list li a{
display: block;
padding: 3px 10px;
}
.tab-panel{
display: none;
}
.tab-panel.active{
display: block;
}
</style>
</head>
<body>
<section class="page">
<div class="tabs">
<ul class="tab-list">
<li class="active">
<a href="#tab-1" class="tab-control">
<h3>第一籤</h3>
</a>
</li>
<li>
<a href="#tab-2" class="tab-control">
<h3>第二籤</h3>
</a>
</li>
<li>
<a href="#tab-3" class="tab-control">
<h3>第三籤</h3>
</a>
</li>
</ul>
<div class="tab-panel active" id="tab-1">
<p>第一籤內容 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magni porro provident aliquam modi nemo officiis, qui obcaecati autem numquam nihil.</p>
</div>
<div class="tab-panel" id="tab-2">
<p>第二籤內容 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reprehenderit sunt laudantium tenetur distinctio dolorum illum necessitatibus iure voluptas ipsam error.</p>
</div>
<div class="tab-panel" id="tab-3">
<p>第三籤內容 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolores consequatur facilis beatae ex dolore et velit omnis repellat quidem sunt!</p>
</div>
</div>
</section>
<script type="text/javascript">
$('.tab-list').each(function(){
var tab = $(this).find('li.active');
var link = tab.find('a');
var panel = $(link.attr('href'));
$(this).on('click','.tab-control',function(e){
e.preventDefault();
var link2=$(this);
var id = this.hash;
if(id && !link2.is('.active')){
panel.removeClass('active');
tab.removeClass('active');
panel=$(id).addClass('active');
tab=link2.parent().addClass('active');
}
})
});
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(905)
<!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">
.tab-list li{
display: inline-block;
}
.tab-list li a{
display: block;
padding: 3px 10px;
}
.tab-panel{
display: none;
}
.tab-panel.active{
display: block;
}
</style>
</head>
<body>
<section class="page">
<div class="tabs">
<ul class="tab-list">
<li class="active">
<a href="#tab-1" class="tab-control">
<h3>第一籤</h3>
</a>
</li>
<li>
<a href="#tab-2" class="tab-control">
<h3>第二籤</h3>
</a>
</li>
<li>
<a href="#tab-3" class="tab-control">
<h3>第三籤</h3>
</a>
</li>
</ul>
<div class="tab-panel active" id="tab-1">
<p>第一籤內容 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magni porro provident aliquam modi nemo officiis, qui obcaecati autem numquam nihil.</p>
</div>
<div class="tab-panel" id="tab-2">
<p>第二籤內容 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reprehenderit sunt laudantium tenetur distinctio dolorum illum necessitatibus iure voluptas ipsam error.</p>
</div>
<div class="tab-panel" id="tab-3">
<p>第三籤內容 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolores consequatur facilis beatae ex dolore et velit omnis repellat quidem sunt!</p>
</div>
</div>
</section>
<script type="text/javascript">
$('.tab-list').each(function(){
var tab = $(this).find('li.active');
var link = tab.find('a');
var panel = $(link.attr('href'));
$(this).on('click','.tab-control',function(e){
e.preventDefault();
var link2=$(this);
var id = this.hash;
if(id && !link2.is('.active')){
panel.removeClass('active');
tab.removeClass('active');
panel=$(id).addClass('active');
tab=link2.parent().addClass('active');
}
})
});
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)