Skip to content

Can't get button value using the val function #3951

@ribeirobreno

Description

@ribeirobreno

In the latest version (0.22.0), getting a button value is not possible with the .val() function.

import * as cheerio from "cheerio";

let ch = cheerio.load(`<form><button value="something">I'm a button</button></form>`);
console.log(ch('button').val());
console.log(ch('button').attr('value'));

The code snippet above will return:

undefined
something

To match jQuery behavior, it should return:

something
something

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions