search

Home  >  Q&A  >  body text

How to give a random value to a class tag?

PHP language program, in a web page article, gives random values ​​(and unique, non-repeating) to all <span class="*">test text</span> tags at the "*", no matter how many characters there are Any letters or numbers will do. For example: <span class="Hug5iR2NvjO9">Test text</span>

赵泽鑫赵泽鑫1071 days ago1285

reply all(9)I'll reply

  • autoload

    autoload2022-01-13 16:59:51

    It mainly depends on how you use it. "*" can be used as a parameter, and php will generate a random number and then replace it

    reply
    0
  • autoload

    But if you change the value of class, is there really no problem with your page style?

    autoload · 2022-01-13 17:08:41
    赵泽鑫

    This is applied within the article, such as every sentence and every paragraph, mainly to prevent crawler collection.

    赵泽鑫 · 2022-01-13 17:23:19
    赵泽鑫

    I wonder if you can explain it in detail. Thank you very much.

    赵泽鑫 · 2022-01-13 18:58:48
    autoload

    What should I say? Because I don't know how to replace this "*" specifically, it seems a little troublesome to implement in PHP. JS is easy to operate. You can directly select all spans and use traversal and classList.add (parameter). You can randomly generate this parameter.

    autoload · 2022-01-14 09:20:54
    赵泽鑫

    Based on your tips, I found a piece of code that can be implemented. Thank you for your help. Thank you.

    赵泽鑫 · 2022-01-25 22:56:31
  • 赵泽鑫

    赵泽鑫2022-01-13 16:33:20

    Can you explain it in more detail? Thank you.

    reply
    0
  • autoload

    autoload2022-01-13 15:38:57

    Using css pseudo-classes

    reply
    0
  • 赵泽鑫

    Can you explain it in more detail? Thank you.

    赵泽鑫 · 2022-01-13 16:34:18
  • Cancelreply