Vue JS Get Selected Option Text Example

Vue JS Get Selected Option Text Example

In this post we will give you information about Vue JS Get Selected Option Text Example. Hear we will give you detail about Vue JS Get Selected Option Text ExampleAnd how to use it also give you demo for it if it is necessary.

In Vue JS, we will learn how to get text of selected option vue js on change event. i will give you simple example of get the text of the selected option using vue.js.

we can easily get selected text value of dropdown in vue js. i give you bellow full example of getting selected option text and value in vuejs.

In this example, we will take a simple dropdown with some options like laravel, php, codeigniter, etc. when you select it. we will get selected option text and value using on change event value vue js.

Example:

<!DOCTYPE html>

<html>

<head>

<title>Vue JS Get Selected Option Text Example - ItSolutionStuff.com</title>

<script src="https://cdn.jsdelivr.net/npm/vue"></script>

</head>

<body>

<div id="app">

<select name="category_id" @change="onChange($event)" >

<option>--- Select Category ---</option>

<option value="1">PHP</option>

<option value="2">Laravel</option>

<option value="3">Codeigniter</option>

<option value="4">Vue JS</option>

<option value="5">Angular JS</option>

</select>

</div>

<script type="text/javascript">

var app = new Vue({

el: '#app',

methods: {

onChange(event) {

var optionValue = event.target.value;

var optionText = event.target.options[event.target.options.selectedIndex].text;

console.log(optionText);

console.log(optionValue);

}

}

})

</script>

</body>

</html>

I hope it can help you…

Hope this code and post will helped you for implement Vue JS Get Selected Option Text Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

54  +    =  56

We accept paid advance and paid guest Posting on our Site : Contact US