简体   繁体   中英

Issue with replacing css/html code with wp hook

I have issue to replace some html content. On WP admin plugin page side I want to apply like this code in plugin default.php (like function.php):

function wpb_hook_javascript() {
    ?>
        <script>
jQuery(function($){
$('.nameofclass').html('<p>test</p>');
});
        </script>
    <?php
}
add_action('wp_head', 'wpb_hook_javascript');

I test only <script></script> on fronted site and works ok, but I want to display some changes in specific css in wp admin dashboard on some plugin page, but that not work good with above wp hook.

Use admin_head hooks.

function wpb_admin_hook_javascript() {
?>
    <script>
        jQuery(function($){
            $('.nameofclass').html('<p>test</p>');
        });
    </script>
<?php
}
add_action('admin_head', 'wpb_admin_hook_javascript');

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