Bir sayfada birden fazla jQuery Script

0 Cevap php

I am brve new to Jquery ve have run into something that if answered will help greatly in the future. I have 2 very simple questions I am using codeigniter, HTML5 ve all php pages as well.

Ben yer kazanmak için kapatmak mümkün olmak istiyorum 4-5 bölümler ile 'bir kenara' bir menü var. Yani 2 basit slideToggle komut kullanıyorum.

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

ve

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

The problem is, if I use button on both, both scripts operate even though I am requesting the script to run on 2 different ID's ( I know the dog ve cat thing is silly, I just threw them in to see if a fake id would work ve it did)

The question is, how can I use button OR a href on both scripts to preserve my styling?

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

Yardım için teşekkürler, bu benim ilk iki komut vardır. En azından onlar çalışır :)

    <div class="menu">
<h2>News Links</h2>

 <a href="#">Display</a>
 <!--
if I use "button" here, both scripts run on tveem
-->
<script>
 $("a").click(function () {
  $('#cat').slideToggle('slow', function() {
    })
});     

benchmark->mark('links_start'); $this->db->order_by('id', 'DESC'); $this->db->limit('10'); $query = $this->db->get('links'); foreach ($query->result() as $row) { echo "link \" title=\"$row->title\" target=\"_blank\">$row->name "; } $this->benchmark->mark('links_end'); ?>
   </div>
   <div class="menu">
   <h2>Archives</h2>
   <button>Display</button> <!--if I use "a" here, both scripts run on tveem
     -->
    <script>
  $("button").click(function () {
  $('#dog').slideToggle('slow', function() {
    })
  });     
  </script>
  <div id="dog">
  <?php
$this->db->order_by('id', 'DESC');
$where = "publish";
$this->db->where('status', $where);
$this->db->select('id, title', FALSE);
$this->db->select('DATE_FORMAT(date, "%b %D %Y")AS date');
$this->db->from('posts');
$query = $this->db->get();
foreach ($query->result() as $row)          

0 Cevap