常用js总结
WdatePicker监视value变化
$("input").bind("propertychange", function() {
if(isNaN($(this).val())){$(this).val("")}
});
必填
function bitian(){
var bt = jQuery("input");
bt.after(" <span style='color:red'>*</span>");
jQuery("#Submit").attr("onclick", "");
jQuery("#Submit").click(function() {
var ll = 0;
bt.each(function(i) {
if (jQuery(this).val() == '') {
ll++;
}
});
if (ll > 0) {
alert("请填写完整!");
} else {
CheckForm();
}
}
获取get变量
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r);
return null;
}
iframe高度自适应
function dyniframesize(down) {
var pTar = null;
if (document.getElementById) {
pTar = document.getElementById(down);
} else {
eval('pTar = ' + down + ';');
}
if (pTar && !window.opera) {
pTar.style.display = "block"
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
pTar.height = pTar.contentDocument.body.offsetHeight + 20;
} else if (pTar.Document && pTar.Document.body.scrollHeight) {
pTar.height = pTar.Document.body.scrollHeight;
}
}
}
CSS截取字符串省略号效果
li a {display: block;width: 120px;overflow: hidden;/*注意不要写在最后了*/white-space: nowrap;-o-text-overflow: ellipsis;text-overflow: ellipsis;}
table布局
table{margin-left:auto; margin-right:auto; line-height:22px;width:190mm; }
.table1{border-collapse:collapse}
.table4{border-collapse:collapse; margin-top:-1px; margin-bottom:-1px;}
.table4 td,.table1 td{ border:1px solid #000; padding:5px; font-size:14px;}
.table2{ border:0; width:100% }
.table2 td{ border:0; }
表格宽度固定不变形
table {table-layout:fixed;word-break:break-all;word-wrap:break-word;}
getJSON遍历
function hq(){
id=jQuery("input").val();
jQuery.getJSON( "/module/chuanbo.php",{sbh:id,rand:new Date().getTime()+Math.random()}, function(j){
for(k in j){
jQuery("input").val(j);
}
});
}
虚拟主机配置
<VirtualHost *:80>
ServerName sz120oa.my0557.com
DocumentRoot e:/oa
<Directory e:/oa>
AllowOverride All
Options All
</Directory>
php_value include_path e:/oa
</VirtualHost>
function hq(){
id=jQuery("input").val();
jQuery.getJSON( "/module/chuanbo.php",{sbh:id,rand:new Date().getTime()+Math.random()}, function(j){
for(k in j){
//alert(jQuery("*").attr("tagName"));
jQuery("*").val(j);
}
});
}
页:
[1]