Home Web Front-end JS Tutorial Detailed explanation of how to set the default selection of the select tag

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

Mar 03, 2018 am 09:12 AM
select set up default

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