The icon in the select optionIn this article, we will create an icon in a select option with the help of JavaScript. We will use the font-awesome library to add icons in the select option. Icon in <select> and <option> tagThe <select> tag is similar in functionality to unordered list <ul> or ordered list <ol> used in HTML to define a list and <option> tag is similar to the list item <li> which specifies the list item in a list. The select and option tags are used to create drop-down menus. It is also called a pull-down list and drop-down list. They allow the user to select single or multiple choices from a list of options. All the choices are not shown on the screen, but they are visible when they pull the drop-down list. They are used to save space as only one item of the list is displayed. It is a paired tag that starts with the opening <select> tag and ends with the closing tag </select>. This tag has to be used with the <option> tag. The <select> tag specifies that the text that follows is a list, and the <option> tag is used to specify the items of the list. Syntax:The various attributes used with the <select> tag are:
The various attributes used with <option> tag are:
We can use the library given below to add an icon in the select option. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"> Let's take various examples of icons in the select option. Example 1:Explanation: In the above example, we have created an icon in the drop-down list with the help of <select> and <option> tag. If we select a particular value from the <option> list value and select the element from the <option> list, it will display a selected icon from the selected options list. Output: The output of this example are given below: Example 2:Explanation: In the above example, we have created an icon in the drop-down list with the help of <select> and <option> tag. If we select a particular value from the <option> list value and after selecting the element from the <option> list, it will display a selected option from the select list. Output: The output of this example is given below. Next TopicWhat is an App Manager |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India