0 votes
by (680 points)

 Hi guys.

I'm trying to do a simple onclick "disable" a button, but I can't seem to get it to work.  I've styled the button with a custom class "spell_button" and had hoped to target it with simple javascript to disable it once it has been clicked.

<span id="Test" class="spell_button"><<button "Test">>
	    document.getElementById("Test").disabled = true;

Any idea where I went wrong? :(

1 Answer

0 votes
by (61.7k points)
selected by
Best answer

The button doesn't have an id of test, the span you wrapped it in does. You need to target the button element itself: 

@@#test;<<button "test">>
    <<run $("#test button").prop("disabled", true)>>

You can use jQuery, it's included in SugarCube. 

by (680 points)
Ah.... thanks.  Works like a charm.  I'm not too well versed in Jquery, but i'll look it up.
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.