css:
/**
* @param
* @arrange (512.笔记) jb51.cc
**/
<style type="text/css">
.imgwarp {
text-align: center;
}
.imgwarp img {
margin-left: auto;
margin-right: auto;
}
</style>
html:
<div class="u" id="bdiv">
<a href="http://" id="bt">按钮</a>
<div id="sdiv"class="imgwarp" style="display:none;">
内容
</div>
</div>
js:
/**
* @param
* @arrange (512.笔记) jb51.cc
**/
<script type="text/javascript">
var lxf = function(selector) {
if (window == this) {
return new lxf(selector);
}
var doms = document.getElementsByTagName(selector);
var arr = [];
for (var i = 0; i < doms.length; i++) {
arr.push(doms.item(i));
}
return this.setArray(arr);
};
lxf.prototype.setArray = function(arr) {
this.length = 0;
[].push.apply(this,arr);
return this;
}
lxf.fn = lxf.prototype;
var $ = lxf;
//each方法
$.fn.each = function(method) {
for (var i = 0,l = this.length; i < l; i++) {
method.call(this[i],i);
}
}
//show方法
$.fn.show = function() {
this.each(function(i) {
alert(i + ":" + this.id + ":" + this.innerHTML);
this.style.display = "block";
});
}
//执行
$('div').show();
</script>