<button class="update vacancy-submit" tabindex="2">Save</button>
$('.vacancy-submit').click(function(){
var type = $(this).attr('class').not('.vacancy-submit');
console.log(type);
});
我正在尝试将按钮类添加到变量中,该变量应为
update
而不是update vacancy-submit
最佳答案
如果始终是头等舱:
$('.vacancy-submit').click(function(){
var type = this.className.split(/\s+/).shift();
console.log(type);
});
FIDDLE