How can I change button value with stylish?

796 views Asked by At

This is the button:

<input type="submit" name="submitbutton" value=" black "><input>

I want to change value "black" to "white" but I can't. How can I change the value with stylish?

2

There are 2 answers

0
Brock Adams On BEST ANSWER

Stylish is an add-on/extension that just allows you to inject CSS. The value of that button is a JavaScript / DOM property; Stylish cannot change those.

You need to install Greasemonkey (Firefox) or Tampermonkey (Chrome).

Then you can run this userscript to change that value:

// ==UserScript==
// @name     _YOUR_SCRIPT_NAME
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// @grant    GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
    introduced in GM 1.0.   It restores the sandbox.
*/
var btn = document.querySelector ("input[name='submitbutton']");
if (btn) {
    btn.value = "White";
}
else {
    alert ("From GM script: Button not found");
}
0
Chirag Mongia On

You cannot change the value of a button using CSS. Though it can be done using JavaScript. This link might help you-

javascript change value of button