您的位置:首页 > Web前端 > JQuery

jquery中的几个注意问题

2017-12-26 09:48 183 查看
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"

}]

以上几点是基本的。但也是很重要的。切记。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: