Adding “data-” attributes with select2

后端 未结 3 1359
眼角桃花
眼角桃花 2020-12-15 06:11

I\'ve seen a lot examples of Select2 option tags set with \"data-\" attributes and I would like to do it.

I\'m using ajax to get the data. I get the

3条回答
  •  忘掉有多难
    2020-12-15 06:47

    I am not sure what exactly you are asking but if you want to add data attribute you can do like this..

    In Jquery:

    $(element).attr('data-info', '222');
    

    In javascript:

    document.getElementById('elementId').setAttribute('data',"value: 'someValue'");
    

提交回复
热议问题