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

Sharing examples of specifying assignment of drop-down boxes using js, jQuery and easyui

小云云
Release: 2018-01-24 09:39:48
Original
1585 people have browsed it

This article mainly shares with you a js, jQuery and easyui implementation of the designated assignment method for the drop-down box. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor to take a look, I hope it can help everyone.

js implementation:

1. Select the i-th option by letting it be selected. The code is as follows: (id is the drop-down box id)

(1) document.getElementById("id").options[i].selected=true;

(2) document.getElementById("messagetoid").selectedIndex = 1; (Select the first option)

2. This is achieved by determining the value of the option. The code is as follows:

document.getElementById("messagetoid").value=""; (select the option whose value is empty)

jQuery implementation:

1. By selecting the i-th option, similar to js implementation 1, the code is as follows:

$("#id").get(0) .selectedIndex =

1; (Select the first option)

2. By judging the value of the option, there are two methods. The code is as follows:

( 1) $("#id").val("123"); (Select the option with value "123")

(2) $("#messagetoid").attr("value" , ""); (Select the option whose value is empty)

EasyUI implementation:

$('#id').combobox('setValue','A'); (Select The value is the option of A,)

Related recommendations:

ajax gets the return parameters of the php page, the method of control assignment

About jquery dynamic assignment id and dynamic id retrieval method sharing

Usage of replace() assignment in js

The above is the detailed content of Sharing examples of specifying assignment of drop-down boxes using js, jQuery and easyui. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!