zoukankan      html  css  js  c++  java
  • JQuery 的遍历方法 $.each

    博主呢最近在公司实习,发现公司基本上都会统一代码风格,今天看到还有很多事用JQuery写的js 请求Ajax与后台进行数据交互的方式 当我看到$each 遍历时 然我想起我学JQuery的时候 于是复习一下

    常用的方式呢 有两种

    方式一:

    1、遍历数值,同时使用索引和内容

    success : function(response) {
    $.each(response.data,function(i, value) {
    $(".mailCheck").append(
    "<input type='checkbox' onClick='putCheck();' name='checkbox' value="+value.mailbox+">"+value.username+""
    );

    方式二:

    2、遍历对象,同时使用成员名称和变量内容

    success:function(response){
    $.each(response.data,function(value) {
    $("#meeting").append(
    "<td> " + "<input type='checkbox' value='response.data[value].username '>"+ response.data[value].username  +  " </td>"
    );
    

      

    代码风格很重要吗? 对很重要!一定要统一,不然对后期的可维护是一种煎熬!!!明年见 祝大家新年快乐!

  • 相关阅读:
    VS1053 datasheet 解读笔记
    C# List Find方法
    git push & git pull 推送/拉取指定分支
    Python 匿名函数
    Python 函数
    java jdk安装与环境变量配置
    Anroid开发环境配置
    Asponse.Cell操作Excel
    C#调试DeBug
    Ext.gridPanel中内容对齐
  • 原文地址:https://www.cnblogs.com/shundong106/p/10193783.html
Copyright © 2011-2022 走看看