dryb38654 2014-09-06 14:53
浏览 13

如何挂钩头块内的div块

I am trying to add a div inside adminhtml/default/default/page/header.phtml, specifically inside <div class="header-right">.....</div>. I know overriding header block would do this, but I don't want to do it that way. So that if someone adds admin theme it'll not mess his design. I'm looking for a solution like jQuery('.header-right').append('<div>This is the div I want to add</div>'); in php which would add content at the end inside the header-right div. Maybe there is a way to parse the header block's html, add my content and replace there again.

I appreciate any hints/help.

<div class="header-top">
    <a href="<?php echo $this->getHomeLink() ?>"><img src="<?php echo $this->getSkinUrl('images/logo.gif') ?>" alt="<?php echo $this->__('Magento Logo') ?>" class="logo"/></a>
    <div class="header-right">
        <p class="super">
         ........
         ........
         ........
        </p>
    </div>
   <div>This is the div I want to add</div>
</div>
  • 写回答

2条回答 默认 最新

  • douyi7283 2014-09-06 18:37
    关注

    Prototype: http://jsfiddle.net/1sxsnkbb/

    <body>
    ...
    <div class="header-top">
        <a href="#">#</a>
        <div class="header-right">
            <p class="super">
             ........
             ........
             ........
            </p>
        </div>
    </div>
    
    <script>
    $$('.header-right')[0].setAttribute('id', 'header-right');
    $('header-right').insert({'after':'<div>This is the div I want to add</div>'} );
    </script>
    ...
    </body>
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度