Zi 字媒體
2017-07-25T20:27:27+00:00
jQuery Include HTML:jQuery替代iframe插入Include HTML方法[JQincludeHTML]
資料來源: https://www.ucamc.com/e-learning/javascript/113-jquery-include-html
GITHUB:https://github.com/jash-git/JQincludeHTML
code:
jquery include HTML
$(document).ready(function(){
$.get("a.html",function(data){ //初始將a.html include div#iframe
$("#iframe").html(data);
});
$(function(){
$('.list-side li').click(function() {
// 找出 li 中的超連結 href(#id)
var $this = $(this),
_clickTab = $this.find('a').attr('href'); // 找到連結a中的href標籤值
if("-1"==_clickTab.search("http://")){ //不是http://執行以下
$.get(_clickTab,function(data){
$("#iframe").html(data);
});
return false
}
})
})
});
body{
background-color: #CCC;
}
.list-side{
list-style-type: none;
}
#iframe {
border: 1px solid #FFF;
padding: 10px;
min-height: 800px;
}
.list-side li {
width: 180px;
}
.list-side li a {
cursor:pointer;
color: #333;
font-weight: bold;
background-color: #FFF;
display: block;
margin-bottom: 1px;
padding-left: 5px;
}
.mmuser {
width: 100%;
}
.list-side li a:hover {
background-color: #666;
color: #FFF;
}
.sa{
width: 250px;
}
#sidebar {
vertical-align: top;
}
JQUERY HTML INCLUDE
about
news
product
UCAMC
教學PDF:
寫了
5860316篇文章,獲得
23313次喜歡