美文网首页
jQuery 样式选择器

jQuery 样式选择器

作者: 三人成师 | 来源:发表于2019-01-18 10:36 被阅读0次

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>Title</title>

    <style>

        li{ list-style-type: none; cursor: pointer; /*font-family: 宋体;*/ }

    </style>

</head>

<body>

<script src="jquery-1.12.1.js"></script>

<script>

$(function () {

    $(".ham").mouseenter(function () {

    $(".ham").next("li").css("backgroundColor","red");//下一个兄弟元素

    $(".ham").nextAll("li").css("font-size","30px");//后面所有的兄弟元素

    $(".ham").prev("li").css("font-style","italic");//前一个兄弟元素

    $(".ham").prevAll("li").css("font-weight","bolder");//前面所有的兄弟元素

    $(".ham").siblings("li").css("font-family","宋体");//所有的兄弟元素

});

$(".ham").mouseleave(function () {

    $(".ham").next("li").css("backgroundColor","");

    $(".ham").nextAll("li").css("font-size","");

    $(".ham").prev("li").css("font-style","");

    $(".ham").prevAll("li").css("font-weight","");

    $(".ham").siblings("li").css("font-family","");

});

});

</script>

<ul>

    <li>哈姆雷特</li>

    <li>哈姆雷特</li>

    <li class="ham">哈姆雷特</li>

    <li>哈姆雷特</li>

    <li>哈姆雷特</li>

    <li>哈姆雷特</li>

    <li>哈姆雷特</li>

    <li>哈姆雷特</li>

</ul>

</body>

</html>

相关文章

  • JQuery基础知识

    jQuery操作DOM jQuery的选择器 基本选择器 层级选择器 过滤选择器 jQuery操作样式 css操作...

  • jquery

    1、选择器 选择器 2、样式添加、属性获取 样式与属性 3、js对象和jquery对象转化 js和jquery转化...

  • 2018-12-08

    call和apply 函数的继承 新增选择器 jQuery加载 jQuery选择器 选择集转移 jQuery样式操...

  • jQuery 学习笔记(一)

    全文介绍 jQuery 中入口函数 jQuery 对象和 DOM 对象 jQuery 选择器 jQuery 样式操...

  • 前端学习之jQuery

    选择器 基本选择器 层级选择器(重点)、基本过滤选择器 筛选选择器 使用jQuery操作DOM 样式操作 样式属性...

  • jQuery 整理

    样式篇 jQuery选择器 ①id选择器:$( "#id" )②类选择器:$( ".class" )③元素选择器:...

  • jQuery(样式和DOM)

    初识jQuery jQuery选择器 jQuery的属性与样式 DOM DOM节点的复制与替换 jQuery遍历

  • 前端笔记14

    jQuery选择器 选择集转移 jQuery的样式操作 click事件 jQuery索引值 jQuery作选项卡 ...

  • jQuery笔记

    1. jQuery 介绍 2. jQuery 的基本使用 3. jQuery 选择器 4. jQuery 样式操...

  • jQuery

    (1)jQuery加载 (2)jQuery选择器 (3)选择集转移 (4)jQuery样式操作 (5)click事...

网友评论

      本文标题:jQuery 样式选择器

      本文链接:https://www.haomeiwen.com/subject/dnbgdqtx.html