jqxSwitchButton 如何在 jquery 中获取值
How jqxSwitchButton get value in jquery?
如何获取和设置 jqxSwitchButton 值?我使用此代码创建一个开关按钮,并希望获取按钮值。但它没有奏效。
<meta charset="UTF-8">
<title>SwitchButton</title>
<link rel="stylesheet" href="style/style_edit.css" type="text/css">
<link rel="stylesheet" href="js/jquery-ui-1.11.4.custom/jquery-ui.css">
<link rel="stylesheet" href="js/jquery-ui-1.11.4.custom/external/jqwidgets/styles/jqx.base.css" type="text/css"/>
<link rel="stylesheet" href="js/jquery-ui-1.11.4.custom/external/jqwidgets/styles/jqx.classic.css" type="text/css"/>
<script type="text/javascript" src="js/jquery-ui-1.11.4.custom/external/jquery/jquery-2.1.4.min.js"></script>
<script src="js/jquery-ui-1.11.4.custom/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.11.4.custom/external/jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.11.4.custom/external/jqwidgets/jqxswitchbutton.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.11.4.custom/external/jqwidgets/jqxcheckbox.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#jqxSwitchButton').jqxSwitchButton({checked: true});
// Get the value.
var value = $("#jqxSwitchButton").jqxSwitchButton('val',true);
var value2 = $("#jqxSwitchButton").val();
console.log(value);
console.log(value2);
// Set value.
$("#jqxSwitchButton").jqxSwitchButton('val', true);
// Set value using jQuery's val().
$("#jqxSwitchButton").val(true);
});
</script>
.HTML:
<div class="switch_options">
<div id="jqxSwitchButton" value="A"></div>
</div>
它返回两个布尔值"true",就像文档说的那样:参数类型值(可选)布尔值返回值布尔如何获取值"A"?表示返回字符串,然后设置值。谢谢!
我使用 attr 来获取和设置值,但不知道为什么 .val() 无法获取值
$("#jqxSwitchButton").attr("value","N");
相关文章:
- 在for循环中未获取JQuery/JavaScript对象值
- 点击获取jQuery上的href属性
- 如何获取jQuery Confirm(jConfirm)值并使用该值检查条件
- 通过传递的参数位置获取jQuery中图像的宽度
- MVC Syncfusion Grid-HTML EJ Grid-获取Jquery中所选行的主键
- 如何获取 jQuery 以触发本机自定义事件处理程序
- 如何获取 jQuery 回调触发返回值
- 如何在wordpress插件中获取jquery中的img url和文件url
- 我想知道如何只激活表单提交,而不获取jquery中ajax url的值
- 如何获取jQuery集合中的第k个元素..作为JQUERY元素
- 从aspx.cs页面获取jquery post中的Null响应而不是json
- 如何获取 jquery 变量 childeren
- 如何从每个对象获取jQuery的“title”和“url”值
- 如何动态获取jquery noConflict()的引用
- 用于获取jQuery元素或值的方法
- 获取jquery数组对象的第n项
- 获取jquery确认在函数中返回的结果
- 获取JQuery UI自动完成元素的索引
- 获取jQuery UI排序后的ID数组
- 获取 jQuery DataTable 中的元素