• Jquery(2)


    1, 隐式迭代,当没有找到控件时,可以按照以下方式处理

    $(function () {
                var elements = $("#txt1");
                if (elements.length <= 0) {
                    alert("没有找到文本框");
                }
                elements.mouseover(function () {
                    alert("移动上来了");
                });
            });

    2,next()获取同辈相邻的下一个元素

    $(function () {
                $("p").click(function () {
                    alert($(this).next().text());
                });
            });

    3,nextall() 获取同辈下面的所有元素

    $(function () {
                $("p").click(function () {
                    alert($(this).nextAll().text());
                });
            });

    4,nextall() 也可以作为数组使用

     $(function () {
                $("p").click(function () {
                    $.each($(this).nextAll("p"), function () {  //添加P元素过滤器
                        $(this).css("background", "red");
                    });
                });
            });

    5,siblings() 获取所有同辈对象

    $(function () {
                $("p").click(function () {
                    $(this).css("background", "blue");
                    $(this).siblings("p").css("background", "red");
                });
            });

    6,链式编程写法

    例子1,$(function(){

      $("p").click(function(){

        $("p").click(function(){

          $(this).css("background","blue").siblings("p").css("background","red");

        });

      });

    });

    例子2,$(function(){

      $("#table1 td").Html("<image url="~/nostar.jpg" />") //table 下的td元素,如果用#table > td 代表table相邻子集的td元素

      .mouseover(function(){});

        $("#table1 td").Html("<image url="~/fillstar.jpg" />").nextall().Html("<image url="~/nostar.jpg" />");

      });

    });

  • 相关阅读:
    状压dp学习笔记
    dbcc log(转)
    日志分析 操作(转)
    Sql server 2005系统表详细说明
    c#读取并分析sqlServer据库日志(转)
    [POJ]1915 Knight Moves
    [JOY]1143 飘飘乎居士的约会
    [POJ]1164 The Castle
    win7注册ocx时出现对DllRegisterServer的调用失败,错误代码为0x80040200解决方案
    注册DLL、OCX的方法
  • 原文地址:https://www.cnblogs.com/guoyinghai/p/Jquery2.html
Copyright © 2020-2023  润新知