+2  A: 

You can used combined selectors:

$("a, button").click(function () {
    $('#cat').slideToggle('slow');
}); 

That will allow you to run the same function when either an a or a button is clicked.

My second question is can you put multiple scripts on a .js file for inclusion and how would you do it? Does each get script tags or some other kind of separator?

A javascript 'script' generally refers to a file included by the script tag, although that usage is ambiguous.

What you've got in your post is a javascript statement, probably inside a script tag on your page:

<script type="text/javascript">
    function helloWorld() {
        alert('Hello world');
    }
</script>

You can do this (inline to the page), or move the contained code out to a .js file and reference it:

<script type="text/javascript" src="myjavascript.js"></script>

Your myjavascript.js file would look like this:

function helloWorld() {
    alert('Hello world');
}

myjavascript.js can contain as much javascript as you'd like. Common approaches are to put grouped functionality into a single javascript file, and include it in the page. This makes it easy to re-use the javascript you've written across multiple pages by including it with the script tag on each page that makes use of it (I assume you've done this with the jquery javascript library already).

You can do the exact same thing that jquery has done, and dump all your javascript into a .js file and use script to load it into your page.

Michael Shimmins
My problem is with the combined selectors is that I want to run the scrips both off 'either' a button OR a link. I dont know how to put 2 scripts on one page that both reference a button and dont run both button scripts at once. Even though I am calling them to work on 2 different DIV's. I am rambling here, but I want to perform 2 'separate' operations both using a script button on both scripts.As for the js file, I assume you would make it look much like codeigniter functions. Just call the function.I hope I am not too confusing here
Brad
I don't think I'm following entirely. Do you want the same code to execute when you click either the button or the link, or do you want different code to execute when you click each of them?
Michael Shimmins
I saw your reply to Matthew Flaschen - glad you got it sorted out. jQuery lets you find DOM elements in a multitude of ways, and is quite powerful, ranging from wide selectors (as you've found with 'button') to very narrow (#id) selector and a heap of other ones in between.
Michael Shimmins
I knew I was rambling. I want the operations to execute separately. If I make both a button then both execute at the same time. Mathew has the answer below. Thank you very much for your hard work in trying to follow me.
Brad
+1  A: 

In re: your 2nd question: The code you posted

$("a").click(function () {
    $('#cat').slideToggle('slow', function() {
    })
});

… is one statement. You can write as many statements as you'd like into a single javascript file or <script> tag. If you have multiple JavaScript files, you can concatenate them into one file and reference that file from a script tag.

Ryan Tenney
To expand, if you have multiple javascript files you can also use multiple script tags.
Michael Shimmins
Ok, that makes sense. thanks
Brad
Thank you Ryan!
Brad
+2  A: 

I think what you want is something like this:

<button id="news_display">Display News</button>

<button id="archive_display">Display Archive</button>

$("#news_display").click(function () {
   $('#news').slideToggle('slow');
});    

$("#archive_display").click(function () {
  $('#archive').slideToggle('slow');
});   

This uses jQuery id selectors for the click events, as you already did in the anonymous functions. That way, they're specific and independent.

Matthew Flaschen
Perfect! now am embarrassed. I should have seen that! TY! Seriously thats exactly what I was looking for. That makes a huge difference
Brad