zoukankan      html  css  js  c++  java
  • jquery内容选择器(根据内容匹配元素)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title>内容选择器</title>
      <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
      <style type="text/css">
      .yang{ border-collapse: collapse; width:500px;height:30px;border:1px solid red;"}
      </style>
      <script  type="text/javascript" src="jquery-1.7.1.min.js"></script>
      <script type="text/javascript">
      /*
        :contains(text)    //根据内容匹配元素
        :empty   //匹配内容为空的元素
        :has(selector)  //匹配包含指定选择器的元素
        :parent //匹配内容不为空的元素
      */
            window.onload=function(){
            $('#btnOk').click(function(){
               //根据内容匹配元素
                $("li:contains('国')").html('水浒传');
                });
            };
      </script>
     </head>
     <body>
    
         <ol>
                <li>三国演义</li>
                <li>西游记</li>
                <li></li>
                <li>红楼梦</li>
         </ol>
    
        <hr/>
      <input type="button" id='btnOk' value='确定'  />
     </body>
    </html>
  • 相关阅读:
    EM
    te2
    te
    XLnet
    GPT
    40.Properties
    38.特殊操作流
    37.I/O流
    35.File
    day68日考
  • 原文地址:https://www.cnblogs.com/yangzailu/p/5845433.html
Copyright © 2011-2022 走看看