They work in concert with html tags and css of a document.
The first jQuery line starts with $()
That prepares the script to be executed. Inside the parentheses, you can put whatever you need to apply the functions. It can be a tag such as $('div') where all div tags are affected by what you write there.
Or, it can be $(document) to apply to the entire document.
Or, $('.myclass') to apply to elements with class="myclass".
Or, $('#myid') to apply to elements with id="myid".
Most of the time you want to execute the jQuery/UI after the DOM is loaded so all the relevant elements are found. In that case, use ready().
$(document).ready()
Back to the accordion. Especially for large pages, you might include a ready command so that it can find the element to apply the accordion.
<script type="text/javascript">
$(document).ready(function() {
$("#myAccordion").accordion();
});
</script>
$("#myAccordion").accordion();
});
No comments:
Post a Comment