Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of if statement

Shulou Source: shulou.com Published: 2022-06-02 10:24:02 09月17日 Update

If sentence example analysis, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

All events contain three elements of the js event:

1, the event source (that is, the tag or element that triggers the event)

2, event name (name of response event)

3. Analyze the response of the event

In this case, it is obvious that the p tag is the event source that triggers the event, onclick is the event name, and the response triggered is not fixed.

That is, it will correspond to different events according to different conditions. So, of course, we need to add a condition, and the specific usage is:

If (condition) {

/ / do something

}

Code:

/ / html part

Input method

to write

Pinyin

Close

/ / js part

Var oul=document.getElementById ("uul")

Function ou () {

If (oul.style.display== "block") {

/ / pay special attention to the equal sign above to judge whether it is equal or not, and the equal sign below is an assignment

Oul.style.display= "none"

} else {

Oul.style.display= "block"

}

}

After reading the above, have you mastered the method of example analysis of if statements? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Events analysis that is conditions examples statements differences that is content names methods more tags equal signs parts problems obvious helpless of course Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi macOS Linux Apple MariaDB