<div id="text">some text</div>
<img src="#" onclick="$.function('http://url.com?q=some+text')"/>
I want the q= to be dynamic using the text in the previous paragraph. I can get the text into a variable
var str = $("#text").text();
but am struggling to output this dynamically.
EDIT:
It's much simpler than I thought, figured out the solution from Darin's answer:
<div id="text"><p>Testing text to speech</p></div>
<div id="textlink"></div>
<img src="#" onclick="$.sound.play('http://translate.google.com/translate_tts?q='+ str)" />
<script>
var str = $("#text").text();
</script>
Just needed to know how to append a variable. Thanks
onclickto do?