jQuery - 在表单字段占位符属性中定位特定字母

geo*_*nto 5 javascript css jquery attributes placeholder

我有表格字段,如<input type="text" placeholder="Name*">.然后我将CSS应用于占位符,因此它是灰色的.但是,我想将星号(*)更改为红色.我如何使用jQuery或Javascript定位属性中的那个字符?

Rit*_*rwa 4

给你,对我有用

<!DOCTYPE html>

    <head>
      <meta charset="utf-8">
       <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">


      <style>
      input::-webkit-input-placeholder:after {
         content: '*'; color: red;
      }
      </style>
    </head>
    <body>
      <input type="text" placeholder="Name"></input>

    <script>

    </script>

    </body>
    </html>
Run Code Online (Sandbox Code Playgroud)