The first thing you’ll need to know to use JavaScript and jQuery in Yii is how to add JavaScript to a Web page. As with any standard Web page, there are two primary options:
Link to an external file that contains the JavaScript code
Place the JavaScript code directly in the page using SCRIPT tags
Just as I assume you’re already comfortable with JavaScript, I’ll also assume you know the arguments for and against both approaches. (Technically, there’s a third option: place the JavaScript inline within an HTML tag. This is not a recommended approach in modern Web sites, however, and I won’t demonstrate it here.)