Get the App
SLTechnology News&Howtos  ›  Development  › 

How to assign the drop-down box by js,jQuery and easyui

Shulou Source: shulou.com Published: 2022-06-01 02:10:39 09月16日 Update

This article mainly explains "js,jQuery and easyui how to achieve the specified assignment of the drop-down box", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "js,jQuery and easyui how to achieve the specified assignment of the drop-down box"!

Js implementation:

1. By letting the I option select the I for the selected implementation, the code is as follows: (id is the drop-down box id)

(1) document.getElementById ("id") .options.selected = true

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

two。 This is achieved by judging the value of option. The code is as follows:

Document.getElementById ("messagetoid") .value= ""; (check option with empty value)

JQuery implementation:

1. By selecting the I option, which is similar to the 1 implemented by js, the code is as follows:

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

1; (select the first option)

two。 There are two ways to do this by judging the value of option. The code is as follows:

(1) $("# id") .val ("123"); (select option with a value of" 123")

(2) $("# messagetoid") .attr ("value", ""); (select option with empty value)

EasyUI implementation:

$('# id'). Combobox ('setValue','A'); (select option with a value of A)

At this point, I believe that everyone on the "js,jQuery and easyui how to achieve the specified assignment of the drop-down box" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Drop-down code content method discrimination learning practical deeper interest practicality practical easy to operate more friends websites channels inquiries Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Microsoft MariaDB MySQL Huawei