jquery中的几个注意问题

本文介绍了使用 jQuery EasyUI 框架时应注意的关键事项,包括文件引用顺序、CSS 和 JS 的正确用法、combobox 组件配置及 JSON 数据格式的要求等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 jquery中引用文件,需要引用4个文件。2个css和2个js。但2个js的顺序不能颠倒。不然会报错。正确的顺序如下:
如:<link rel="stylesheet" type="text/css" href="./common/easyui/themes/default/easyui.css">
  <link rel="stylesheet" type="text/css" href="./common/easyui/themes/icon.css">
  
  <script type="text/javascript" language="javascript" src="./common/easyui/jquery-1.7.2.min.js"></script>
  <script type="text/javascript" language="javascript" src="./common/easyui/jquery.easyui.min.js"></script>


jquery-1.7.2.js必须在jquery.easyui.min.js的前面。不然会报错。


2 引用css文件时。必须添加rel属性和type属性。不然会导致不能正确的显示样式。
如:<link rel="stylesheet" type="text/css" href="./common/easyui/themes/default/easyui.css">
  <link rel="stylesheet" type="text/css" href="./common/easyui/themes/icon.css">


3 应用css文件时。link标签不用结尾标签。而引用js文件时。script标签必须有结尾标签</script>不然会导致错误。切记。
如:<link rel="stylesheet" type="text/css" href="./common/easyui/themes/default/easyui.css">
  <link rel="stylesheet" type="text/css" href="./common/easyui/themes/icon.css">
  
  <script type="text/javascript" language="javascript" src="./common/easyui/jquery-1.7.2.min.js"></script>
  <script type="text/javascript" language="javascript" src="./common/easyui/jquery.easyui.min.js"></script>


4 在jsp界面使用jquery的默认处理函数。类似于jquery的load函数。$(function(){...})
如:$(function(){
  $("#combobox1").combobox({
  width:100,
  //height:10,
  panelHeight:"auto",
  valueField:"id",
  textField:"text",
  url:"./json/combobox_json.json"
  });


5 使用combobox时。可以使用input标签,也可以使用select标签。都可以。
如:<input type="text" id="combobox1" name="combobox1" value=""/>
    <br/><br/>
    <select id="select1" name="select1">


-------------js-------
$(function(){
  $("#combobox1").combobox({
  width:100,
  //height:10,
  panelHeight:"auto",
  valueField:"id",
  textField:"text",
  url:"./json/combobox_json.json"
  });
 
  $("#select1").combobox({
  width:100,
  //height:100,
  panelHeight:"auto",
  valueField:"id",
  textField:"text",
  url:"./json/combobox_json.json"
  });
  })


6 combobox的属性中没有height属性。使用也无效。
如:$("#combobox1").combobox({
  width:100,
  //height:10,
  panelHeight:"auto",
  valueField:"id",
  textField:"text",
  url:"./json/combobox_json.json"
  });


7 combobox属性中有valueField属性和textField属性。这是下拉框的值和显示值。
如:$("#combobox1").combobox({
  width:100,
  //height:10,
  panelHeight:"auto",
  valueField:"id",
  textField:"text",
  url:"./json/combobox_json.json"
  });
8 combobox属性中有url属性。该属性可以通过文件来为下拉框赋值。是json文件
如:$("#combobox1").combobox({
  width:100,
  //height:10,
  panelHeight:"auto",
  valueField:"id",
  textField:"text",
  url:"./json/combobox_json.json"
  });
9 combobox中可以通过json文件为下拉框赋值。但是json文件中必须是双引号"符号。而不能是单引号'符号。必须使用双引号才能正确的显示。切记必须使用双引号。为了以后保证正确。统统使用双引号。
如:[{
"id":"123",
"text":"text7"
},
{
"id":"234",
"text":"test8"
}]


10 combobox可以通过json文件赋值。但是json文件的格式是类似于jsonArray格式的。
如:[{
"id":"123",
"text":"text7"
},
{
"id":"234",
"text":"test8"
}]


以上几点是基本的。但也是很重要的。切记。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值