简体   繁体   中英

Add class to specific table php or jquery solution?

Im building wordpress theme based on bootstrap, and on default wordpress calendar widget, styling is not matched with bootstrap styling.

However it's very easy to match width of columns in calendar widget.

When widget is activated it's wrapped in

<table id="wp-calendar">

If i am somehow able to add class to that table with that specific id i would solve problem with styling.

So basically instead of

<table id="wp-calendar">

i need to have

<table id="wp-calendar" class="table table-responsive table-striped">

Is there solution to add class to that specific table with that id?

Some php function or jquery?

使用jQuery

$("#wp-calendar").addClass("table table-responsive table-striped");
$('#wp-calendar').addClass('table table-responsive table-striped');

Using jQuery you may do it like:

// document ready
$(function(){
    $('#wp-calendar').addClass('table table-responsive table-striped');
});

Well, in jQuery the solution would look like:

$('#wp-calendar').addClass('table table-responsive table-striped');

References:

You can obviously modify the raw HTML and hard code the class name

<table id="wp-calendar" class="table table-responsive table-striped">

Or You can use JQuery function addClass

$('#wp-calendar').addClass('table table-responsive table-striped');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM