简体   繁体   中英

Remove title from select2

I am using select2 . I need to remove title of selected values. My code is like below.

<li class="select2-selection__choice" title="C Volunteer" data-select2-id="select2-data-16-lf0b"></li>

Source code is like below.

在此处输入图像描述

Output is like below.

在此处输入图像描述

Here's a minimal solution for your use case:

$("#select2-data-16-lf0b").removeAttr("title")

You can select the elements by their class and remove its attribute this way.

$('.select2-selection__choice').removeAttr('title')

hope have helped you.

A simple solution to select the selected vales. Do it any action either its selection or unselect.

$("yourselector").on("select2:select select2:unselect", function (e) {
    $(this).removeAttr("title");       
});

This may help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM