WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

in a sidebar I have:

<div id="my_id"> [shortcode]</div>

It outputs a title that when hovered on drops down to show a menu.

When hovering on the title a background color shows up and disappears when the mouse moves down to the menu items.

I need for the background color to remain as long as the menu has focus, I need something like:

If #my_id has focus then .my_link {background:red;}

I have looked and the only thing that looked promising was (not really sure how to use this)


$(document).ready(function() {    

         .focus(function() {                



.focus {

In functions.php:

function load_scripts() {
   wp_enqueue_script('my_javascript_file', 'http://example.com/wp-content/themes/Child-Theme/js_focus.js', array('jquery'));
add_action('init', 'load_scripts');

Then in style.css:

.focus .my_link {background:red;}

Is this a good approach?, if so (not working at the moment) I only want focus on the menu to give the background color.

If not a good approach any other ideas all are welcomed and appreciated

Thanks Tim

share|improve this question
Did you wp_register_script first? codex.wordpress.org/Function_Reference/wp_register_script, and don't use the init hook, use wp_enqueue_scripts or admin_enqueue_scripts hooks. – soulseekah Mar 30 '12 at 19:12
up vote 1 down vote accepted

Your jQuery is not correct (syntax and logic), this isn't really a WordPress question. To toggle focus effects you can do something like this, http://stackoverflow.com/questions/5608181/jquery-toggle-focus

share|improve this answer
Thanks both for your imput – Tim Mar 31 '12 at 12:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.