11_css

作者: 虎三呀 | 来源:发表于2018-02-09 13:35 被阅读0次
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>11_css</title>
</head>
<body>
<p style="color: blue;">尚硅谷的后裔</p>
<p style="color: green;">太阳的后裔</p>

<!--
设置css样式/读取css值
  css()
-->
<script src="js/jquery-1.10.1.js" type="text/javascript"></script>
<script type="text/javascript">
  /*
   1. 得到第一个p标签的颜色
   2. 设置所有p标签的文本颜色为red
   3. 设置第2个p的字体颜色(#ff0011),背景(blue),宽(300px), 高(30px)
   */
  //1. 得到第一个p标签的颜色
  //console.log($('p:first').css('color'))

  //2. 设置所有p标签的文本颜色为red
  //$('p').css('color', 'red')

  //3. 设置第2个p的字体颜色(#ff0011),背景(blue),宽(300px), 高(30px)
  $('p:eq(1)').css({
    color: '#ff0011',
    background: 'blue',
    width: 300,
    height: 30
  })

</script>
</body>
</html>

相关文章

网友评论

      本文标题:11_css

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