js 笔记
提交表单
$("#ggForm").submit();
jquery ready
$(document).ready(function () { alert("ready"); });
html编辑器 ueditor
<script id="contentContainer" name="content" type="text/plain"> </script>
var ue = UE.getEditor('articleContainer');
ue.ready(function () {
ue.setHeight(400);
});
var content = ue.getContent();
select change 事件
$('#indexarea').change(function () { indexareaChange(); });
select 异步请求获取数据
var strHtml = "<option value=''>--请选择--</option>"; var indexsvc = $("#indexsvc").val(); var articleType = $("#type"); var articleTypeBjHtml = ""; $.ajax({ type: "post", data: { querySvcId: indexsvc }, url: "/Article/xxx", success: function (data) { var list = data.list; $.each(list, function (index, item) { strHtml += "<option value=\"" + item.Id + "\">" + item.Name + "</option>"; articleTypeBjHtml += "<option value=\"" + item.Id + "\">" + item.Name + "</option>"; }); articleType.empty(); articleType.append(strHtml); //设置选中某一项 var hd_type = $("#hd_type").val(); articleType.attr("value", hd_type); } });
jquery ul 添加 li数据
$.ajax({ url: "/PublicMessage/xxx", type: "post", data: {}, success: function (data) { var list = data.list; var strHtml = ""; $.each(list, function (index, item) { strHtml += "<li><a href=\"/Information/xxx?articleTypeId=" + item.Id + "\">" + item.Name + "</a></li>"; }); $("#nav ul.sub").eq(0).empty(); $("#nav ul.sub").eq(0).append(strHtml); } });
post 方式
$.post("/AdvanceBooking/MyCommissionerListZy", { page: pageclickednumber, PageSize: 5 }, function (data) { for (var i = 0; i < data.list.length; i++) { html2 += GetHtml(data.list[i]); } $("#wdzylist").empty(); $("#wdzylist").append(html2); }, "json");
返回前一个页面
window.history.back(-1);
选中第1个
$("#nav ul.sub").eq(0)
c# 提交html字符
[ValidateInput(false)]
MVC返回json list 数据
public JsonResult ServicePointArticleType(Guid? querySvcId) { if (!querySvcId.HasValue) return Json(""); var result = ArticleDal.GetArticleTypeList(querySvcId.Value); return Json(new{list = result}); }
js radio 判断是否选中某个值
var toTop = $("#bj input:radio[name='decide02']:checked").val()=="1";
checkbox
$("#userEms").click(function () { if (true === $(this).is(":checked")) { $("#tabEms").show(); } else { console.log("userEms unchecked"); $("#tabEms").hide(); } });