douzi115522 2016-11-17 18:36
浏览 55

将ul类添加到函数输出

I have function. It shows like that.

    <div id="sidebar-category"><h2 class="sidebar-title black">Konular</h2>     <ul>
    <li class="cat-item cat-item-2"><a href="http://www.domain.com/cats/girisimler/" >Girişimler</a>
</li>
    <li class="cat-item cat-item-3"><a href="http://www.domain.com/cats/isletme-yonetimi/" >İşletme Yönetimi</a>
</li>
    <li class="cat-item cat-item-4"><a href="http://www.domain.com/cats/proje-yonetimi/" >Proje Yönetimi</a>
</li>
    <li class="cat-item cat-item-6"><a href="http://www.domain.com/cats/web-dunyasi/" >Web Dünyası</a>
</li>
        </ul>
</div>

How can I add class in <ul> ?

This is my function :

function arphabet_widgets_init() {

    register_sidebar( array(
        'name'          => 'Home right sidebar',
        'id'            => 'home_right_1',
        'before_widget' => '<div id="sidebar-category">',
        'after_widget'  => '</div>',
        'before_title'  => '<h2 class="sidebar-title black">',
        'after_title'   => '</h2>',
    ) );

}
add_action( 'widgets_init', 'arphabet_widgets_init' );

I show HTML with this code

<?php dynamic_sidebar( 'home_right_1' ); ?>
  • 写回答

3条回答 默认 最新

  • dongzhong2018 2016-11-17 18:42
    关注

    I see you are using WordPress. Can you edit the ul in the widget to add the class manually? If not, you could always use jQuery (present in WordPress) to add a class:

    $('#sidebar-category ul').addClass('myClass');
    

    Be sure it loads after the dom is ready:

    $(document).ready(function() {
        $('#sidebar-category ul').addClass('myClass');
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line