Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!