Where do i put the $ scripts?


#1

Hey, im trying to add some scripts to my site, lets take for example the search button.

class=“ui search” // this is html…

But this part :
$(’.ui.search’)
.search({
source: content
})
;

var content = [
{ title: ‘Andorra’ },
{ title: ‘United Arab Emirates’ },
{ title: ‘Afghanistan’ },
// etc
];

where do i put the “$” part? i tried to insert everything into a script tag but it didnt work… thank you!


#2

You probably inserted your JS stuff somewhere in <head>...</head> or at least before your search element was created. Technically this is a question of jQuery people )) But you should always put your JS into a “dom ready” function. For instance

<html>
<head>
    <!-- include jquery files here -->
    <script>
        $(function() {
            //your JS code goes here
        });
    </script>
</head>
</body>
    <!-- your page here -->
</body>
</html>