A
A
Anton2017-08-06 09:51:39
Python
Anton, 2017-08-06 09:51:39

Responsive horizontal layered menu, how to fix highlighting bug?

Hello.
There is a small problem, I point at one of the sections, the section changes color, everything is fine, you can see it, and when the list of subcategories of this category pops up and point at one of the subcategories, the color of the parent category changes and is not particularly visible, I attached a screen, you can see it. How can I make it so that when I hover over the categories in the submenu, the color of the parent category does not change. the font itself. color it.
4443b8302f344f71a0a667665d4ef717.pngThe menu itself is here:
Uploaded without js.
https://jsfiddle.net/tjuLjd0t/

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2019-03-17
@DVoropaev

Lutz - "Learning Python", chapter 20, page 596

As you know, names that are assigned inside a function are considered local by default - they are located in the scope of the function and exist only while the function is running. But I haven't said yet that local variables are defined statically, at compile time, in def statements, and not according to run-time assignments. This feature is responsible for some of the most bizarre newsgroup posts from novice programmers.
Usually, if no value is assigned to a name within a function, it will be looked up in the scope of the enclosing module. But look what happens if you add an assignment statement to X after you use it.
X = 99
>>> def selector():
... print(X) # Переменная еще не существует!
... X = 88 # X классифицируется как локальная переменная
... # То же самое происходит при “import X”, “def X”...
>>> selector()
Traceback (most recent call last):
...текст сообщения об ошибке опущен...
UnboundLocalError: local variable ‘X’ referenced before assignment

A message was received that the variable was not defined, but the reason for its appearance is not obvious. This program code is compiled by the interpreter at the time of typing in the interactive shell or at the time of module import. At compile time, Python detects an assignment to X and infers that X is a local name throughout the body of the function. But during the execution of the function, due to the fact that by the time the print statement was called, the assignment operation had not yet been performed, the interpreter reports that the name is not defined. According to this naming rule, it says that the local variable X was accessed before it was assigned a value. In fact, any assignment within a function creates a local name. Import operation, =, nested def statements, nested class definitions, and so on, are all treated that way. The problem arises because the assignment operation makes the names local to the entire function, not just to the part of it that follows the assignment statement.

Reading textbooks is helpful.

ⓒⓢⓢ, 2017-08-06
Websaytovsky @ws17

So?
https://jsfiddle.net/tjuLjd0t/2/
see line 62

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question