Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8366147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:50:33+00:00 2026-06-09T12:50:33+00:00

Hey guy’s I can’t figure out why my code doesn’t work when I have

  • 0

Hey guy’s I can’t figure out why my code doesn’t work when I have nested elements…

Here’s my html code

<head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="head.js"></script>
    <title>Test Page</title>
    <link rel="stylesheet" type="text/css" href="mock.css"
    />
</head>
<body>
    <div id="subMenu">
        <ul>
            <li class="button boxshadow">
                <a class="subnav" href="#">Test</a>
                <ul>
                    <li class="button boxshadow">
                        <a class="subnav" href="#">Testing</a>
                    </li>
                    <li class="button boxshadow">
                        <a class="subnav" href="#">Tested</a>
                    </li>
                </ul>
            </li>
            <li class="button boxshadow">
                <a class="subnav" href="#">Works</a>
            </li>
            <li class="button boxshadow">
                <a class="subnav" href="#">Other</a>
                <ul>
                    <li class="button boxshadow">
                        <a class="subnav" href="#">Other</a>
                    </li>
                    <li class="button boxshadow">
                        <a class="subnav" href="#">Other</a>
                    </li>
                </ul>
            </li>
            <li class="button boxshadow">
                <a class="subnav" href="#">Last</a>
                <ul>
                    <li class="button boxshadow">
                        <a class="subnav" href="#">Last1</a>
                    </li>
                    <li class="button boxshadow">
                        <a class="subnav" href="#">Last2</a>
                    </li>
                    <li class="button boxshadow">
                        <a class="subnav" href="#">Last3</a>
                    </li>
                    <li class="button boxshadow">
                        <a class="subnav" href="#">Last4</a>
                    </li>
                </ul>
            </li>
        </ul>
    </div>
</body>

my CSS

.button {
    background: url(images / button.jpeg) no - repeat;
    background - size: 100 % ;
    position: relative;
    display: block;
    float: left;
    width: 165px;
    text - align: center;
    left: 25px;
    margin: 5px 10px;
}

and my javascript/jquery

$(document).ready(function() {
    $('.button').bind("mouseover", function() {
        $(this).css("box-shadow", "0 0 10px 5px #B6B6B6");

        if ($(this).text().toLowerCase() == "test".toLowerCase()) {
            a = "blah."
            b = "blah."
            c = "blah."
            d = "blah."
            e = "blah."
            f = "blah."

            handle(a, b, c, d, e, f);
        }
        if ($(this).text().toLowerCase() == "works".toLowerCase()) {
            a = "blah"
            b = "blah."
            c = "blah"
            d = "blah"
            e = "Blah"
            f = "Blah"

            handle(a, b, c, d, e, f);
        }

        $(this).bind("mouseout", function() {
            $(this).css("box-shadow", "5px 5px 10px #070707");
        })
    })
})​

So from this everything is working expect when i have sub items in my list like in “test” which has 2 sub lists, my if statement will work on “test if I remove the sub list exactly like “works”. As soon as I add sub items to my main list my if statement stops working even though I know the mouseover is working cause it is working the .css part of the code..

Any ideas on what’s happening here would be greatly appreciated.. I am new to JQuery and am moving my site to it rather than java script. thx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:50:35+00:00Added an answer on June 9, 2026 at 12:50 pm

    I am not sure you can use .toLowerCase() directly on a string as it is a function part of the String object.

    Thus, you know exactly its value since you hard code it, why using this function on the right part of the equation?

    if ($(this).text().toLowerCase() == "test")
    

    should solve your problem, to test it out you should try console.log(your condition).

    EDIT

    Based on your comment and your code, it seems to be a matter of selector and/or html structure. You target .button which is applied to an li which contains more li items.
    You can “flatten” your html to the same level, or more simply, adapt your selector and classes.
    But I think the best approach is the following :

    $(this).find("a").first().text(); // or "a:first"
    

    There is probably something prettier but you can understand where this is going? Using .first() to prevent going into the sub li.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys having this really simple problem but cant seem to figure out have
hey guys I have the follow code in js: $(document).ready(function(){ $(.replyLink).click(function(){ $(#form-to-+this.id).html(htmlForm()).toggle(500); return false;
Hey guys this is my html code: <div class=nakupy> <li class=icn_kategorie><a href=#>Nákupy</a> <div class=sub_menu>
hey guys how to make these php html links codes possible. i have tried
Hey everyone I have a basic search function here that allows me to search
Hey all here are my tables i have placed in a DIV for each.
Hey everyone, a new guy here in C#.Net. I'm trying to make an application
hey guy I have a question which is why php and mysql so popular
Hey all i have posted the code to the countdown counter i am using.
Hey all i am trying to figure out a way to see what all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.