javascript 小技巧

 在选择查询条件为空的情况下的查询结构:

 

var params = "1=1";

params += name == "" ? "" : "&name=" + name;

params += queryUserName == "" ? "" : "&queryUserName=" + queryUserName;

params += template =="" ? "" : "&template=" + template;

params += asCategory == "" ? "" : "&asCategory=" + asCategory;

params += asSerial == "" ? "" : "&asSerial=" + asSerial;

params += osImage == "" ? "" : "&osImage=" + osImage;

params += status == "" ? "" : "&status=" + status;

  下拉判断被选第几个和选择器使用:

        $("select[name='container'] option:selected").index()

   ajax contentType 类型:

        默认值: "application/x-www-form-urlencoded"。发送信息至服务器时内容编码类型。

                默认值适合大多数情况。如果你明确地传递了一个 content-type 给 $.ajax() 那么它必定会发送给服务器(即使没有                   数据要发送)。

      

    jquery里面不常见用法:

       $td = $("td[status]", $row);  作用是在$row对象里面找到 td中存在status属性的对          象,并返td对象。

       $("button.stop, button.stopped")

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章