[JQuery]学习总结
1. Jquery 选择多个class 如何精确匹配
$("div[class='class1 class2']").css({ "margin-bottom": "0px" });
$("input[name='selectedConstractorSid'][type='text']").val();//取值
$("input[name='selectedConstractorSid'][type='text']").val(“赋给你一个值”);//赋值值
2. 隔行换色
function RefreshTableColor() { var trs = $("#yourID tbody tr"); for (var i = 0; i < trs.length; i++) { if (i % 2 == 0) { trs[i].style.backgroundColor = "#e0e0df"; console.log("use"); } else { trs[i].style.backgroundColor = "#fff"; } } };
3. 操作table
$(document).on("click","#yourID tbody tr td",function () { var yourSid = $(this).parent().find("td:first div").html(); console.log(yourSid ); });
4. Ajax cache在1.2默认为true
$.ajax({ url: "test.html", cache: false, //或者设置true success: function(html){ $("#results").append(html); } });