Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
I'm tring to create very simple wordpress plugin but my javascript not working

I had already connected the javascript file

Enqueue script function is:

function wpplugin_admin_scripts(){
   wp_enqueue_script(
    'myplugin-admin',
    WPPLUGIN_URL.'admin/js/eylonplugin-admin.js',
    ['jquery'],
    time()
   );

 }
 add_action('admin_enqueue_scripts', 'wpplugin_admin_scripts', 100);

But while I'm trying to style some attributes I can't.

This is the function that I'm adding HTML to my plugin page :

 function my_plugin_plugin_html(){ ?>
    
    <div id="wrap container">
        <h3> Plugin Header </h3>
    
        <form method="post" action='options.php'>
            <?php settings_errors(); ?>
            <?php settings_fields('my_plugin_option_group'); ?>
            <label for="my_plugin_field_plugin">Top bar color</label>
            <input name="my_plugin_field" id="my_plugin_field_plugin" type="text" value="<?php echo get_option('my_plugin_field')?>"><br>        
            <div>
            <?php submit_button('my_plugin I love you');?> 
        </form>
        <h2 id="js_checking">my_plugin<span class="selected_output"></span></h2>
        <script> </script>
        </div>
        <h3>My color is red</h3>
        <button id="try_me">Try me!</button>
    <?php
}

Here I'm trying to style my h3 attribute but nothing happens. But the alert is working.

$("h3").css("color","red");
alert("Hello world");
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Wrap your jquery code with as below so you can add codes without using jQuery instead of $:

(function ($) {

YOUR CODES HERE

})(jQuery);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda