获取select里的value值和option里面的值
var majorID = $("#id option:selected").text();
两个数组组成json格式数据
var jsonArray = [];
for(var i = 0;i<userIdArray.length;i++){
var json = {};
for(var j=0;j<userNamesArray.length;j++){
if(i==j){
json.userName = userNamesArray[j];
json.userId = userIdArray[i];
jsonArray.push(json);
}
}
}
var notPerson = JSON.stringify(jsonArray);
url编码:closedLoopRule = encodeURIComponent(closedLoopRule);
单选框选择有效
if($('#checkbox_INDICATOR_REPORT_TEMPLATE').is(':checked')) {
$("#HtmlButton_tianbao button").attr("disabled", false).removeClass("ui-button-detail-disable");
}else{
$("#HtmlButton_tianbao button").attr("disabled", true).addClass("ui-button-detail-disable");
}
:checked
匹配所有选中的被选中元素(复选框、单选框等,select中的option),
:selected
匹配所有选中的option元素
$("select option:selected")
attr(name|pro|key,val|fn)
设置或返回被选元素的属性值。
单选框的禁用
$('input:radio:first').attr('checked', 'checked');
addClass(class|fn)
为每个匹配的元素添加指定的类名。
$("p").addClass("selected");
$("p").addClass("selected1 selected2");
each(callback)
以每一个匹配的元素作为上下文来执行一个函数。
$("img").each(function(i){
this.src = "test" + i + ".jpg";
});
如果你想得到 jQuery对象,可以使用 $(this) 函数。
可以使用 ‘return’ 来提前跳出 each() 循环。 return false;
Window setInterval()
可按照指定的周期(以毫秒计)来调用函数或计算表达式。
setInterval('alert("Hello");', 3000);
text([val|fn])
取得所有匹配元素的内容。
结果是由所有匹配元素包含的文本内容组合起来的文本。这个方法对HTML和XML文档都有效。
$("select").on('change',bind(this,this.changeView));
缓存到浏览器:localStorage.setItem(‘row’,JSON.stringify(row));
跳转页面:location.href="/pages/authority/UserEditor.html"
返回页面:history.back()
在iframe脚本中获取host
window.top.location.host;