js开发参考-编辑1
<select id="SelectType" name="SelectType"> <option value="0">请选择</option> <option value="1">分类一</option> <option value="2">分类二</option> </select>
<select id="SelectCity" name="SelectCity">
<option value="0">请选择</option>
</select>
$(".SelectType").change(function () { GetSelectType(); });
$('.ListPage').on("click", 'dl dt', function () {
$(this).find("video").attr('controls', 'controls');
$(this).find("span").addClass('dn');
var dataID = $(this).attr('DataID');
});
$(".modal-dialog .btn-default").click(function () {
window.location.href = "@Url.Action("Index", "Home")";
});
$(".modal-dialog .close").click(function () {
window.location.href = "@Url.Action("Index", "Home")";
});
$(function () { function GetSelectType() { var vType = $('#SelectType option:selected').val(); $ajax("@Url.ActionUrl("GetSelectTypeList")", { vType: vType }, function (data) { $("#SelectCity").empty(); $("#SelectCity").append("<option value=\"0\">请选择城市</option>"); if (data.length > 0) { for (var i = 0; i < data.length; i++) { if (thisid == data[i].id) $("#SelectCity").append("<option value=\"" + data[i].id + "\" selected=\"selected\">" + data[i].name + "</option>"); else $("#SelectCity").append("<option value=\"" + data[i].id + "\">" + data[i].name + "</option>"); } } }); }
function GetSelectType() {
$.ajax({
url: "@Url.Action("List", "Home")",
data: { typeid: $("#TypeId").val() },
type: "POST",
dataType: "json",
async: false, //同步执行
success: function (result) {
var dataJson = result.dataList;
var ids = dataJson[0].ids;
},
error: function (errmsg) {
alert("数据加载失败!");
}
});
};
function GetHits(iDataID) {
$.ajax({
url: "Ajax/AjaxShow.aspx",
data: { DataID: iDataID },
type: "POST",
dataType: "json",
success: function (data) {
var iCount = data.list[0].JsonCount
$("#divPraise" + iDataID).text(iCount);
}
});
}
});
<input type="button" id="txtCheckAll" name="txtCheckAll" value="全选" onclick="CheckAll();" /> <input type="button" id="txtCheckNo" name="txtCheckNo" value="去选" onclick="CheckNo();" />
<input type="checkbox" id="cbBox" name="cbBox" value="1" onclick="GetCheckBox(this);" />
<input type="hidden" id="TypeIds" name="TypeIds" />
//全选
function CheckAll() { $(".divList").find("input[type='checkbox']").prop("checked", true); $("#TypeIds").val($("#hfTypeIds").val()); }
//去选 function CheckNo() { $(".divList").find("input[type='checkbox']").removeAttr("checked"); $("#TypeIds").val(""); }
//点击box
function GetCheckBox(inputBox) {
var result = "";
var arrBoxSelect = $("#TypeIds").val(); //数组box的值
var thisBoxValue = $(inputBox).val() + ",";//当前box的值
if ($(inputBox).is(':checked')) {
result = arrBoxSelect + thisBoxValue;
} else {
result = arrBoxSelect.replace(thisBoxValue, "");
}
$("#TypeIds").val(result);
}
$(function () {
//加载后默认选中Box
var listBox = $("input[name='cbBox']");
for (var i = 0; i < listBox.length; i++) {
var varSelect = $("#TypeIds").val();
var arrSelect = varSelect.split(",");
for (var j = 0; j < arrSelect.length; j++) {
if (listBox[i].value == arrSelect[j]) {
listBox[i].checked = true;
}
}
}
}
<input asp-for="Number" placeholder="请输入数值" onblur="SetIsintorfloat(this,0)" onkeyup="SetIsintorfloat(this,0)"/> <input type="text" id="Number" name="Number" placeholder="请输入数值" onblur="SetIsintorfloat(this,0)" onkeyup="SetIsintorfloat(this,0)">
//验证数值 function SetIsintorfloat(obj, type) { if (type == 0) { var reg = /^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,10})?$/;//浮点 if (!reg.test($(obj).val())) { $(obj).val(""); } } else { var reg = /^\d+$/;//整数 if (!reg.test($(obj).val())) { $(obj).val(""); } } } function SetIsintorfloat(obj, type) { // var timerSeconds = 1; var interval = setInterval(function () { if (timerSeconds <= 0) { clearInterval(interval); } if (timerSeconds <= 0) { setTimeout(function () { if (type == 0) { var reg = /^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,10})?$/;//浮点 if (!reg.test($(obj).val())) { $(obj).val(""); } } else { var reg = /^\d+$/;//整数 if (!reg.test($(obj).val())) { $(obj).val(""); } } }, 300); } timerSeconds--; }, 2000); }
$(".modal-dialog .btn-default").click(function () { window.location.href = "@Url.Action("Index", "Home")"; }); $(".modal-dialog .close").click(function () { window.location.href = "@Url.Action("Index", "Home")"; });