js获取html元素

    xiaoxiao2021-03-25  51

    获取body标签下的第x个button(从0开始)的显示内容

    alert($("body button:eq("+x+")").html());

    获取当前元素的上一个元素

    $("body button:eq("+0+")").parent().prev().css("background","red")

    获取当前元素的下一个元素

    $("body button:eq("+0+")").parent().next().css("background","red")

    获取当前元素的父元素

    $("body button:eq("+0+")").parent().css("background","red")

    获取当前元素的子元素

    $("body button:eq("+0+")").children().css("background","red")
    转载请注明原文地址: https://ju.6miu.com/read-26170.html

    最新回复(0)