Using <script> instead of <% function()...
I used a script element instead of <% ... %> markup in this particular use-case because the #link (and #link2) element doesn't exist at the time that the code within the <% ... %> markup is executed. You can test this yourself by first replacing the relevant code in Passage A with the following and then look at the Console output after running it.
<%
console.log('link inline: ' + $('#link').length);
%>
... the output should read link inline: 0 which indicates that the #link ID'ed element hasn't been added to the page's DOM yet.
If you replace the above in Passage A with the following and do the same test.
<script>
console.log('link script: ' + $('#link').length);
</script>
... then the output should read link script: 1 which indicates that enough time has passed for the #link ID'ed element to of been added to the page's DOM.
According to the readme, perhaps I wouldn't be able to use s.variable...
That is correct, you can't access a story variable from within a script element using that syntax however you can access them via the story.state object.
The following passage content uses Javascript to output the current value of the health story variable to the console.
<% s.health = 100 %>
<%
console.log('via markup: health: ' + story.state["health"]);
%>
<script>
console.log('via script: health: ' + story.state["health"]);
</script>