wyo ha scritto:
I've some functions which I'd like to use outside of jQeury in normal
HTML, e.g.
<script type="text/javascript">
$(document).ready(function() {
function collapse (i) {
$('#expanded_'+i).hide();
}
});
</script>
...
<img src="images/plus01.png onclick="javascript: collapse (17)">
<div id="#expanded_17">...</div>
What do I have to write at the onclick?
Why don't you declare the function outside the document.ready ?
Why don't you add a class to the img and then bind the function directly?
<script type="text/javascript">
$(document).ready(function() {
$('.collapse').bind('click', function collapse (i) {
$('#expanded_'+i).hide();
});
});
</script>
...
<img src="images/plus01.png class="collapse" onclick="javascript: collapse
(17)">
<div id="#expanded_17">...</div>