douxun7992 2015-01-05 09:37
浏览 19

是否可以使用函数编辑DIV标签ID名称?

I have a plugin that uses 3 completely identical divs on the page, using the same classes.

<div class="my-class"> <div class="my-class"> <div class="my-class">

I would like to edit the code of the plugin and add an id to each div, so I can work with it later using css.

But I don't want to touch the parent code due to the later update issues.

Is there a way to add the id tag to a div using just functions placed in functions.php file ??


Guys, also 1 additional question following the 1 above.

You have downvoted this question -2. I have recently received a message from administrator about my account restriction due to this. I don't think I asked a stupid question and I'm not a coder my self so maybe it was stupid, but obviously I'm just trying to understand why you didn't take it very well and what type of questions should I avoid in the future. Your comment would be really appreciated, specially the one who gave it a downvote. Cheers.

  • 写回答

3条回答 默认 最新

  • douzhe1264 2015-01-05 09:40
    关注

    You can differ them using CSS, without need to add them ID attribute.

    <div class="my-class"></div>
    <div class="my-class"></div>
    <div class="my-class"></div>
    
    <style>
        .my-class {width: 200px; height: 100px; background: red;} /* rules for all .my-class elements, eg. width&height, whatever */
        .my-class:nth-child(2) {background: green}
        .my-class:nth-child(3) {background: blue}
    </style>
    

    http://jsfiddle.net/fwy38om7/

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题