This article mainly introduces the JS method of switching to display hidden content by clicking on a link, involving javascript mouse event response and dynamic transformation of page element attributes related operating techniques. Friends who need it can refer to it. I hope it can help everyone.
Let’s take a look at the running effect first:
##The specific code is as follows:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>www.jb51.net 点击链接切换显示隐藏内容</title> <style> a { cursor: pointer; color: red; } #p1, #p2 { display: none; } </style> </head> <body> <a onclick="con(1)">显示内容1</a> <a onclick="con(2)">显示内容2</a> <p id="p1">11111</p> <p id="p2">22222</p> <script> flag = "p1"; function con(i){ //参数传递时传递字符串似乎有问题,这里采用的是数字传参 document.getElementById(flag).style.display = "none"; document.getElementById("p" + i).style.display = "inline"; flag = "p" + i; } </script> </body> </html>
JS implements click cycle switching of display content
Angular implements schedule function (can add and hide display content) detailed explanation
JS How to implement click cycle switching to display content
The above is the detailed content of JS click link to switch to display hidden content. For more information, please follow other related articles on the PHP Chinese website!