jquery show / hide parts of the page

 

 Use the crowd: do not move any js, html only know of.

 

This article explains how to use jquery to display hidden pages related areas.

    1. First, we have two div are: frm_Win, frm_Mac. Wherein each of the other one display Link (id = "frm_WinShow", id = "frm_macShow").
    2. Add reference jquery jquery Head area in the reference (<script type = "text / javascript" src = "jquery-1.4.1.js"> </ script>) Note: typically comprise long jquery-xxxjs can (where xxx is the version number) that do not need to control, and that version is generally applicable.
    3. Add Link click event (<script> tag is not part of being below the code).
                           Introduction statement:
                                . 1 $ ( "# xxx"); -------- indicates is that stuff (where xxx is the id attribute of the element content)
                                . 2 $ ( "# xxx") show ();. -------- let this thing [xxx] display
                                . 3 $ ( "# xxx") hide ();. -------- let this thing [xxx] Hide

4. $ ( "# xxx") css ( "aaaa", "bbbbb");. -------- change [xxx] css attributes aaa bbb value of this thing

                                5.$("#xxx").click(function () {                                    
                                
                                }); ----------- let this thing [xxx] when clicked, actions performed inside (refer to 2,3,4 steps).

After the contents of 6.js in the current row is a comment // part.

 

 1  < head >
 2  < script  type ="text/javascript"  src ="Scripts/jquery-1.4.1.js" ></ script >
 3  </ head >
 4  < body >
 6      < div  id ="frm_Win"  style ="display: none;" >
 7         WinWinWinWinWinWinWinWinWinWinWinWinWinWinWinWinWinWin  < href ="javascript:"  id ="frm_WinShow" >
 8             Down Mac </ a >
 9      </ div >
10      < div  id ="frm_Mac" >
11         MacMacMacMacMacMacMacMacMacMacMacMacMacMacMacMacMacMac  < href ="javascript:"  id ="frm_macShow" >
12             Down Win </ a >
13      </ div >
14      < script  type ="text/javascript" >
15         $("#frm_WinShow").click( function () {
16             $("#frm_Mac").show(); // .css("display", "block");
17              $("#frm_Win").hide(); // .css("display", "none");
18          });
19         $("#frm_macShow").click( function () {
20             $("#frm_Win").show(); // .css("display", "block");
21              $("#frm_Mac").hide(); // .css("display", "none");
22          });
23      </ script >   </ body >   

 


 

 

Reproduced in: https: //www.cnblogs.com/netwenchao/archive/2012/05/17/2506423.html

Guess you like

Origin blog.csdn.net/weixin_34375233/article/details/93607873