').val()).toBeUndefined();
});
+ it('(): on button should get value', () => {
+ const val = $('#btn-value').val();
+ expect(val).toBe('button');
+ });
+ it('(): on button with no value should get undefined', () => {
+ const val = $('#btn-valueless').val();
+ expect(val).toBeUndefined();
+ });
it('(): on select should get value', () => {
const val = $('select#one').val();
expect(val).toBe('option_selected');
@@ -1013,7 +1021,7 @@ describe('$(...)', () => {
it('(fn) : should no op elements without attributes', () => {
const $inputs = $(inputs);
const val = $inputs.removeClass(() => 'tasty');
- expect(val).toHaveLength(15);
+ expect(val).toHaveLength(17);
});
it('(fn) : should skip text nodes', () => {
diff --git a/src/api/attributes.ts b/src/api/attributes.ts
index db246e62b9..cd7cd14f99 100644
--- a/src/api/attributes.ts
+++ b/src/api/attributes.ts
@@ -797,6 +797,7 @@ export function val(
? option.toArray().map((el) => text(el.children))
: option.attr('value');
}
+ case 'button':
case 'input':
case 'option': {
return querying