HTML:
<div class="form-group ">
<select class="form-control input-sm col-xs-2 game-select" data-game="LuckyTuesday">
<option value="" disabled selected>Select Game </option>
<option id="1" data-name="Direct 1" data-minNumber="1" data-maxNumber="1">
Direct 1
</option>
<option id="2" data-name="Direct 2" data-minNumber="2" data-maxNumber="2">
Direct 2
</option>
</select>
</div>
JavaScript:
$('select').change(function () {
let gameType = $(this).find(':selected').attr('data-name');
//How to can I use "game-select" class to get "data-game" att?
});
答案 0 :(得分:2)
您只需使用data()
jQuery函数即可获得$(this).data('game');
的值:
from tkinter import *
window = Tk()
window.geometry("400x400")
btn1 = Button(text='button 1')
btn2 = Button(text='button 2')
btn3 = Button(text='button 3')
btn1.grid(row=0, column=0, sticky='ew')
btn2.grid(row=0, column=1, sticky='ew')
btn3.grid(row=0, column=2, sticky='ew')
window.grid_columnconfigure([0,1,2],weight=1)
window.mainloop()