1.Jquery解析Json数据:
var remark_msg=jQuery.parseJSON(result);
$.each(remark_msg,function(i,n)
{
$("#remark_content").val(n.remark);
$("#remark_msg").html(n.name+"于"+n.rtime+"备注!");
} )
2.数据确认:
var r=confirm('您确认要清除所分配的医院吗?');
if(r==true)
{
par='';
}else
{
return false;
}
3.删除空格:$.trim();
4.保留小数位数:money.toFixed(2);
5.数字验证:
if($.trim(rtime)==""||isNaN(rtime))
{
$("#remark").html("准备时间输入错误,请检查!");
$("#readytime").select();
return false;
}
6.刷新页面:location.reload();
7.JS取整:Math.ceil(pagesum/pagesize);
8.去处最后一个字符:did=did.substring(0,did.length-1);
9.JS处理PHP数组:
$("#specialty").empty();
var spe_sel;
switch(value)
{
case "1":
spe_sel=<?php echo json_encode($specialty_sel['临床'])?>;
break;
case "2":
spe_sel=<?php echo json_encode($specialty_sel['中医'])?>;
break;
case "3":
spe_sel=<?php echo json_encode($specialty_sel['口腔'])?>;
break;
case "4":
spe_sel=<?php echo json_encode($specialty_sel['公共卫生'])?>;
break;
case "5":
spe_sel=<?php echo json_encode($specialty_sel['人文医学'])?>;
break;
default:
spe_sel=<?php echo json_encode($specialty_sel['临床'])?>;
break;
}
for(var item in spe_sel)
{
$("#specialty").append("<option value='"+item+"'>"+spe_sel[item]+"</option>");
}
10.JS调试:
1. console.log("Hello World!");
2.
console.group("第一组信息");
console.log("第一组第一条");
console.log("第一组第二条");
console.groupEnd();
console.group("第二组信息");
console.log("第二组第一条");
console.log("第二组第二条");
console.groupEnd();
3.console.dir()可以显示一个对象所有的属性和方法。
4.onsole.dirxml()用来显示网页的某个节点(node)所包含的html/xml代码。
5.console.assert()用来判断一个表达式或变量是否为真
6.console.trace()用来追踪函数的调用轨迹。
7.console.time()和console.timeEnd(),用来显示代码的运行时间。
8.console.time()和console.timeEnd(),用来显示代码的运行时间。
11.选中与隐藏:
if($("#s_speaker").attr("checked")=="checked"&&$("#s_speaker").is(":hidden"))
12.Jquery→RadioButon取值:
$("input[name='speakertype']:checked").val();
13.正整数验证:
var reg=/^[0-9]*[1-9][0-9]*$/;
!reg.test(mtime)
14.Bootstrap model的显示与隐藏:
$("#check_modal").modal();
$("#check_modal").modal('hide');
15.Jquery Ajax提交:
$.ajax({
type: 'POST',
url: '/kol/index/select_doctor_msl' ,
data: "sel_key="+ search_key+"&user_id="+msl_id+"¤tpage="+currentpage,
success:function(result)
{
$('#<?php echo $user_id?>_show').html(result);
},
dataType:"text"
});
16.字符串分割:
var answers=

