您的位置:首页 > 产品设计 > UI/UE

LigerUI学习笔记之二 TextBox(上)

2012-09-04 10:17 204 查看
不说了直接上代码

头部引入

<link href="../lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" /> 皮肤样式文件 放第一位
<script src="../lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="../lib/ligerUI/js/core/base.js" type="text/javascript"></script>
<script src="../lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script> 插件js


html代码如下

<body style="padding: 20px">
<input id="txt1" type="text" />
<br />
<input id="txt2" type="text" /><br />
<input type="button" id="btnSet" value="设置值" />
<input type="button" id="btnGet" value="获取值" />
<input type="button" id="Button1" value="禁用" />
<input type="button" id="Button2" value="启用" />
</body>


这才是正宗的

<script type="text/javascript">
$(function () {
//            $("#txt1").ligerTextBox({ nullText: '不能为空', label: 'LABEL' });
//            $("#txt1").ligerTextBox({ nullText: '不能为空222', label: 'LABEL44' });
//需要设置两次才有效果 有bug

$("#txt1").ligerTextBox({ nullText: 'Your Name', label: '用户名', labelWidth: 100, labelAlign: 'center' });
$("#txt2").ligerTextBox({ nullText: 'Your Name', label: '密  码', labelWidth: 100, labelAlign: 'center' });
//$("#txt2").ligerTextBox({ initValue: '不能为空' ,label:'设置初始值', labelWidth:100, labelAlign:'right'});

//设置值
$("#btnSet").bind('click',
function () {
$("#txt1").ligerGetTextBoxManager().setValue("My name is Tom");
}
);
//获取值
$("#btnGet").bind('click', function () {
var name = $("#txt1").ligerGetTextBoxManager().getValue();
if (name != "") {
alert(name);
}
else {
alert("No");
}
});
//禁用
$("#Button1").bind('click', function () {
$("#txt1").ligerGetTextBoxManager().setDisabled();
});
//启用
$("#Button2").bind('click', function () {
$("#txt1").ligerGetTextBoxManager().setEnabled();
});
});
</script>


主要的知识点:

使用ligerGetTextBoxManager获取对象

设置值:setValue(value);

获取值:getValue();

禁用按钮:setDisabled();

启用按钮:setEnabled();

单词不要错了就行了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: