jQuery selected selector

preview_player
Показать описание
Link for all dot net and sql server video tutorial playlists

Link for slides, code samples and text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

In this video we will discuss jQuery :selected selector.

To select all checked checkboxes or radio buttons, we use :checked selector. To select all selected options of a select element use :selected selector.

How to get selected option from single select dropdown in jquery : We want to get the selected option text and value

Replace < with LESSTHAN symbol and > with GREATERTHAN symbol.

<html>
<head>
<title></title>
<script type="text/javascript">
$(document).ready(function () {
$('#selectCountries').change(function () {
var selectedOption = $('#selectCountries option:selected');
});
});
</script>
</head>
<body style="font-family:Arial">
Country:
<select id="selectCountries">
<option selected="selected" value="USA">United States</option>
<option value="IND">India</option>
<option value="UK">United Kingdom</option>
<option value="CA">Canada</option>
<option value="AU">Australia</option>
</select>
<br /><br />
<div id="divResult"></div>
</body>
</html>

How to get all selected options from multi select dropdown in jquery : We want to get all the selected options text and value.

<html>
<head>
<title></title>
<script type="text/javascript">
$(document).ready(function () {
$('#selectCountries').change(function () {
var selectedOptions = $('#selectCountries option:selected');
var resultString = '';
resultString += 'Value = ' + $(this).val() +
', Text = ' + $(this).text() + '<br/>';
});
$('#divResult').html(resultString);
}
});
});
</script>
</head>
<body style="font-family:Arial">
<select id="selectCountries" multiple="multiple">
<option selected="selected" value="USA">United States</option>
<option value="IND">India</option>
<option value="UK">United Kingdom</option>
<option value="CA">Canada</option>
<option value="AU">Australia</option>
</select>
<br /><br />
<div id="divResult"></div>
</body>
</html>

Please note : Hold down the CTRL key, to select more than one item.
Рекомендации по теме
Комментарии
Автор

Your teaching style goes at very normal speed which suits All. Thanks a lot for your great effort.

mohammedsardar
Автор

really you have a gift of teaching, your tutorial are the best and my favorite. really tank you so so so much

mahamogira
Автор

It is really helpful. Great job venkat sir

sindhujavijayakumar
Автор

You are doing the great job, it is very useful for fresher's. Thank you so much sir

sindhujavijayakumar
Автор

Explicou bem, super curti a aula e era exatamente o que estava precisando entender! Obrigado!

FilipeAvelinoGiacomo
Автор

We thank you for this wonderful effort ... and we call on you to always reconcile explanation ... the most wonderful and easy and simple ... you're really a wonderful man and we hope you how the reports in Crystal Report, environment or any other application ... please

dodyretw
Автор

We thank you for this wonderful effort ... and we call on you to always reconcile explanation ... the most wonderful and easy and simple ... you're really a wonderful man and we hope km of how to work in an environment reports

dodyretw
Автор

+Kudvenkat  I am having multiple offers all because of your videos . Met your brother too (Bangalore) . Currently focusing on MVC & Angular JS . Your videos is a boon to any individual . Hoping to follow ur path in near future (help others :) once capable ) .

pranaya
Автор

just few hours spent for this "Hold down the CTRL key, to select more than one item."

coolNotCold
Автор

Many many thanks, for your helpful all tutorial . how are you, sir ? Sir multiple selectors do not work.When I clicked any option then change and Replaced text

shahadatkhan
Автор

Sir, can you please provide a series on complete step by step website building in Asp.net and a series on JAVA, it will be pretty helpful to know how to build a fully functional website with the knowledge  gathered from all the asp.net tutorials.

RayhanAhmedsimanto
Автор

For the the select  i  think you can also do like this
<select id="select" >
     <!-- insert your options here -->
</select>
JQuery
$(function(){
    
            var option = $(this).val();
           confirm(option); // this will happen if you just need the value
      });
});

bensosfrequents
Автор

you should update all old videos
it seen 7 years old !

ppp
Автор

HI video on how to edit datatable using jquery?

chimwemwekhunga
Автор

Nice video!!! I need your help. I want to count (number) of the selected items. For example if I select 3 countries in a label write "3 countries". Please help!

DChristop
Автор

how to bind multiple select List using Jquery
plz help me

sagargirase
Автор

HI video on how to edit datatable using jquery?

chimwemwekhunga