0

I'd like to know..

How could I change my 3 main categories links, so they call a javascript function?

I'm using Snapshot Theme from WooThemes.

Here's the current state of the website:

http://www.mpn.p.ht/wp_br2/

The categories I'd like to change the links to a javascript function call, are: Masculino, Feminino and Infantil.

They are at a container with class widget.

EDIT:

I´ve changed the jquery.

I've tried to use jquery in index.php:

$(document).ready(function() {

    $(".widget ul li > a").not("ul li ul li>a").attr("href", "javascript:hideMenu();showSubMenu('m-submenu');");
$(".widget ul li+li > a").not("ul li+li ul li>a").attr("href", "javascript:hideMenu();showSubMenu('f-submenu');");
$(".widget ul li+li+li > a").not("ul li+li+li ul li>a").attr("href", "javascript:hideMenu();showSubMenu('i-submenu');");

});

But, it seems that some sub-categories are calling the javascript function. In other words, my .not() it´s not working in some cases.

What could I do?

Thanks.

5
  • The Answer is: $(document).ready(function() { $(".widget ul li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a )").attr("href", "javascript:hideMenu();showSubMenu('m-submenu')"); $(".widget ul li+li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a )").attr("href", "javascript:hideMenu();showSubMenu('f-submenu');"); $(".widget ul li+li+li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a )").attr("href", "javascript:hideMenu();showSubMenu('i-submenu');"); }); I must use :not to discard any possible match for every main category. May 8, 2013 at 18:28
  • 1
    So you found the answer? Next time you should use StackOverflow.com to find jQuery answers. You are using wordpress, but you're problem is jQuery. Have a nice day Brazuca.
    – gdaniel
    May 8, 2013 at 18:30
  • I´m not sure. Maybe there´s a wordpress core code better answer. Editing a category.php, category-template.php, or something. That would make life easier. I will have to add the jquery and javascript functions to each page. May 8, 2013 at 18:43
  • 1
    If you've got your answer, be sure to post and mark as answered.
    – ckpepper02
    May 8, 2013 at 18:45
  • Have to wait some hours until there May 8, 2013 at 18:50

1 Answer 1

0

The Answer is:

$(document).ready(function() {
    $("#f-submenu").hide();
$("#m-submenu").hide();
$("#i-submenu").hide();
$(".widget ul li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a     
)").attr("href", "javascript:hideMenu();showSubMenu('m-submenu')");
$(".widget ul li+li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a 
)").attr("href", "javascript:hideMenu();showSubMenu('f-submenu');");
$(".widget ul li+li+li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a 
)").attr("href", "javascript:hideMenu();showSubMenu('i-submenu');");
});   

It seems I must enter every possible undesirable match in each :not

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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