Home >Web Front-end >JS Tutorial >About js code to obtain and control the properties of radio and select_javascript skills

About js code to obtain and control the properties of radio and select_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:06:521030browse

To achieve the goal: 1. Click "Anonymous Group", automatically jump to: member type "Private Group", access control "Group Members"
2. Click "Public Group", automatically jump to: member type "Real Name Group"

 About js code to obtain and control the properties of radio and select_javascript skills

The first is to get the event of clicking the radio, using the jquery library. After getting the event, determine which radio it is. By judging which radio is checked, the linkage transformation is performed. The problems encountered include compatibility with IE and Firefox events, and then setting the selected attribute of options in select.

Compatible with IE and Firefox using var ie=document.all;var nn6=document.getElementById&&!document.all;

To set the selected attribute of options in select, use var t=document.getElementsByName("select1")[0][1]; t.setAttribute("selected","selected");

When setting the selected attribute, document.getElementsByName("select1").options is usually used, but Firefox reports undefined. So after traversing, I used an array to solve it.

The following is the complete code that achieves goal 1:
html

Copy code The code is as follows: