8 : elements ( string -- result )
9 #! Call JQuery's $ function
10 window { "result" } "" "$" { "string" } alien-invoke ;
12 : html ( string -- element )
13 #! Set the innerHTML of element using jQuery
14 { } "" "html" { "string" } alien-invoke ;
16 : bind-event ( name element quot -- )
17 >function swap { } "" "bind" { "string" "function" } alien-invoke ;
22 "<button id='test'>Press Me</button>" "#playground" elements html ;
25 "click" "#test" elements [ "clicked" alert ] bind-event ;
30 >r "click" "#test" elements r> [ continue ] curry bind-event
31 "Waiting for click on button" alert
34 drop "Click done!" alert
38 #! Display the string in an alert box
39 window { } "" "alert" { "string" } alien-invoke ;