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">>
    <<script>>
	    document.getElementById("Test").disabled = true;
    <</script>>
<</button>></span>

Any idea where I went wrong? :(

1 Answer

0 votes
by (63.1k 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)>>
<</button>>@@

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.
...