Home > Web Front-end > JS Tutorial > body text

Detailed explanation of how to set the default selection of the select tag

小云云
Release: 2018-03-03 09:12:08
Original
2163 people have browsed it

This article mainly shares with you an option method for setting the default selected option of the select tag. It has a good reference value and I hope it can help everyone.

There are two methods.

The first method is to set the selected item through the attribute of label is:

var val = document.all.Item.options[document.all.Item.selectedIndex].text
var i=document.getElementById( 'sel' ).options[document.getElementById( 'sel' ).selectedIndex].value;
Copy after login

Some others The techniques for operating the