Want select2 not to select first option by default

27,614 views
Skip to first unread message

pratee...@gmail.com

unread,
Jun 3, 2016, 3:51:36 PM6/3/16
to select2
HI Folks,

I am using select2 library over a search bar. What happens is when the search results appear in the drop-down as list select2 automatically gives first option as selected, which I don't want.

I want no option to be selected by default instead want to get it selected whenever the user presses and up/down arrow key after the results appear.

Can some-one please help me in achieving this ?

Thanks.

bruno.m...@gmail.com

unread,
Aug 16, 2016, 6:58:46 PM8/16/16
to select2, pratee...@gmail.com
This is not an answer at all and i'm sorry for this false hope but an answer would surely help me too !

Kevin Brown

unread,
Aug 16, 2016, 9:34:55 PM8/16/16
to select2, pratee...@gmail.com

This behaviour exists not because Select2 is forcing it, but because the browser is auto-selecting the first option for you. We can't control that, we can only work around it. Your best option is to use the placeholder support in Select2 and include a blank option tag as your default selection.


On Tue, Aug 16, 2016, 18:58 <bruno.m...@gmail.com> wrote:
This is not an answer at all and i'm sorry for this false hope but an answer would surely help me too !

--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at https://groups.google.com/group/select2.
For more options, visit https://groups.google.com/d/optout.

bruno.m...@gmail.com

unread,
Aug 17, 2016, 6:14:48 AM8/17/16
to select2, pratee...@gmail.com
Thanks ! :D

jp3...@gmail.com

unread,
Feb 15, 2018, 11:03:12 AM2/15/18
to select2
// This may help some one although this is an old post.

$('#keywordselect').select2({
placeholder: 'Select...',
closeOnSelect: false,
multiple: true,
});

// one clears the box content and the other clears the highlighting
$('#keywordselect').val(null);
$('.select2-selection__rendered').html('');

jaji...@gmail.com

unread,
Jul 26, 2018, 3:54:08 PM7/26/18
to select2

bharath...@gmail.com

unread,
Aug 1, 2018, 5:42:03 AM8/1/18
to select2

add empty option to top of the <select> tag . Do this before intialization
<option></option>

mikibe...@gmail.com

unread,
Dec 10, 2019, 5:04:32 AM12/10/19
to select2
If its still relevant to someone, here's the fix:

  $("#yourelementid").select2({ [options]... });

  ..
  $("#yourelementid").val("")
  $("#yourelementid").trigger("change");

Joost Roetgering

unread,
Sep 26, 2022, 4:13:02 AM9/26/22
to select2
For anyone that still needs it. If you add multiple="multiple" to the select element it won't auto select the first option. For example:

<select class="select-class"  multiple="multiple">
<option value="value">value</option>
</select>
Op vrijdag 3 juni 2016 om 21:51:36 UTC+2 schreef pratee...@gmail.com:

Sumit Pradhan

unread,
Oct 12, 2022, 4:53:12 AM10/12/22
to sel...@googlegroups.com
Thank you for your response.

Best of Regards,
Sumit Pradhan
Cell: 9841960029


--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.

sumit khatri

unread,
Jan 17, 2023, 2:50:39 AM1/17/23
to select2
If you are working on change events,


you can use $("#select").val(0);
untill you donot have option with val=0;

२०२२ अक्टोबर १२, बुधबार का दिन १४:३८:१२ UTC+5:45 बजे pradhan...@gmail.com ले यस्तो लेख्नुभयो:

Emma Snow

unread,
Dec 21, 2025, 8:19:07 AM12/21/25
to select2

Thirty one Products offers a wide range of high-quality items designed to simplify daily life and enhance personal style. From practical essentials to stylish accessories, their products combine functionality with modern design. With Thirty one Products, you can enjoy reliable, well-crafted items that make everyday tasks easier and more enjoyable.

Facebook lite apk

unread,
Jan 13, 2026, 1:16:45 PMJan 13
to select2
FF Beta testing is a platform where you can test upcoming new features, like characters, weapons, modes and maps etc.

Phill Jones

unread,
Jan 20, 2026, 3:22:13 PMJan 20
to select2
SSRMovie APK is an Android app that allows users to stream and download the latest movies and TV shows. It features a simple, easy-to-use interface, providing quick access to a wide range of content. With SSRMovie APK, Android users can enjoy high-quality entertainment anytime and anywhere on their devices.

Youcine APK

unread,
Jun 2, 2026, 12:33:33 AM (13 days ago) Jun 2
to select2
O Youcine APK at https://you-cineapk.pro/ Última Versão V1.17.2 é um aplicativo muito útil para assistir filmes e séries em um só lugar. A interface é simples e fácil de usar, mesmo para iniciantes. A qualidade do streaming é boa e funciona de forma estável. No geral, é uma ótima opção para entretenimento.

Anslayer

unread,
Jun 2, 2026, 3:43:05 AM (13 days ago) Jun 2
to select2
The variety of genres in anime slayer app from animesslayer.com really surprised me — from romance and action to mystery and slice of life. It’s also great that I can search by year or category, making it easier to find exactly what I’m looking for. Totally worth having on any anime fan’s phone.

Ostora

unread,
Jun 2, 2026, 5:34:27 AM (13 days ago) Jun 2
to select2
The streaming quality on Alostora TV is surprisingly good for a free app. Even on slower internet, it adjusts automatically and runs smoothly. I enjoy watching football, and the match schedule feature helps me plan ahead. Overall, it’s a reliable and convenient app.

Senpai Stream

unread,
Jun 3, 2026, 5:32:19 AM (12 days ago) Jun 3
to select2
What I like most about Senpai Stream APK is its fast performance. Videos start quickly and play without interruptions. The design is user-friendly and easy to understand. It’s a reliable app for daily streaming.

On Stream

unread,
Jun 6, 2026, 5:04:27 AM (9 days ago) Jun 6
to select2
I recently tried the OnStream App download and it works really well for streaming movies and TV shows. The interface is simple and easy to navigate, even for new users. I like how quickly the content loads and the video quality is quite good. Overall, it’s a convenient app for watching entertainment anytime.

Through

unread,
Jun 9, 2026, 2:33:17 AM (6 days ago) Jun 9
to select2
whatsapp gold allows better control over conversations. It provides extended privacy tools. The layout feels clean and organized. Many users prefer its modern look.

Through

unread,
Jun 9, 2026, 2:37:35 AM (6 days ago) Jun 9
to select2

whatsapp gold premium apk offers improved chat customization. Users can adjust fonts and styles. The app runs smoothly on Android devices. Many people appreciate its creative options.

Philli

unread,
Jun 9, 2026, 2:38:44 AM (6 days ago) Jun 9
to select2
egybest apk download latest version  offers a simple interface and a wide variety of movies and series.

On Tuesday, 9 June 2026 at 14:33:17 UTC+8 Through wrote:

Abdul Rehman

unread,
Jun 9, 2026, 2:40:47 AM (6 days ago) Jun 9
to select2
snaptube 5.0 apk stands out because it supports many websites for video and audio downloads. The ability to convert videos into MP3 format is especially convenient. I also appreciate that downloads can be managed within the app. Overall, it is very practical for offline media lovers.

Through

unread,
Jun 9, 2026, 2:42:22 AM (6 days ago) Jun 9
to select2
I love the smooth interface and wide variety of channels available on drama live arabic.

stick war

unread,
Jun 9, 2026, 2:48:45 AM (6 days ago) Jun 9
to select2
Snaptube APK 2026 is a great choice for people who want to watch videos offline anytime. It works smoothly on most Android phones without heavy resource usage. The download quality options are flexible for storage saving. It’s a reliable tool for building an offline media library.
Reply all
Reply to author
Forward
0 new messages