简体   繁体   English

如果我不能多次使用id来调用函数,该怎么办?

[英]What do I do if I can't use an id more than once to call a function?

I tried asking this before but I don't think I was as clear as I should have been. 我曾经尝试过问这个问题,但我不认为我应该做的清楚。 Sorry for the repeat, but I am new to this and just trying to figure it out. 很抱歉重复一遍,但是我对此并不陌生,只是想弄清楚。 I am trying to call a function with the same id multiple times. 我试图多次调用具有相同id的函数。 I am guessing this can't be done, so what do I need to do instead. 我猜这不能完成,所以我需要做什么。 I have the noConflict in because I am using other jquery versions on the page. 我有noConflict,因为我正在页面上使用其他jquery版本。 The scrollmenu references one of those other ones. 滚动菜单引用了其他菜单之一。 You will see all this if you you at the page I am working on. 如果您在我正在处理的页面上,您将看到所有这一切。 http://www.mac-av.com/test2/ http://www.mac-av.com/test2/

$.noConflict();
jQuery(document).ready(function($) 
{
    $("#scrollmenu");


$("#e_emd").click(function () {
$("#e_em").show();
$("#e_v").delay(1200).fadeOut("slow");
$("#e_s").delay(1200).fadeOut("slow");  
$("#e_l").delay(1200).fadeOut("slow");  
});

$("#e_vd").click(function () {
$("#e_em").delay(1200).fadeOut("slow");
$("#e_v").show();
$("#e_s").delay(1200).fadeOut("slow");  
$("#e_l").delay(1200).fadeOut("slow");  
});  

$("#e_sd").click(function () {
$("#e_em").delay(1200).fadeOut("slow");
$("#e_v").delay(1200).fadeOut("slow");
$("#e_s").show(); 
$("#e_l").delay(1200).fadeOut("slow");  
});  

$("#e_ld").click(function () {
$("#e_em").delay(1200).fadeOut("slow");
$("#e_v").delay(1200).fadeOut("slow");
$("#e_s").delay(1200).fadeOut("slow");  
$("#e_l").show();
});  


});  
<div id="scrollmenua">| 
<a id="e_emd" href="#Event_Management" class="panel">Event Management</a> | 
<a id="e_vd" href="#Video" class="panel">Video</a> | 
<a id="e_sd" href="#Sound" class="panel">Sound</a> | 
<a id="e_ld" href="#Lighting" class="panel">Lighting & Staging</a> | 
</div>

<div id="scrollmenub">| 
<a id="e_emd" href="#Event_Management" class="panel">Event Management</a> | 
<a id="e_vd" href="#Video" class="panel">Video</a> | 
<a id="e_sd" href="#Sound" class="panel">Sound</a> | 
<a id="e_ld" href="#Lighting" class="panel">Lighting & Staging</a> | 
</div>

<div id="scrollmenub">| 
<a id="e_emd" href="#Event_Management" class="panel">Event Management</a> | 
    <a id="e_vd" href="#Video" class="panel">Video</a> | 
<a id="e_sd" href="#Sound" class="panel">Sound</a> | 
<a id="e_ld" href="#Lighting" class="panel">Lighting & Staging</a> | 
</div>

<div id="scrollmenub">| 
<a id="e_emd" href="#Event_Management" class="panel">Event Management</a> | 
<a id="e_vd" href="#Video" class="panel">Video</a> | 
<a id="e_sd" href="#Sound" class="panel">Sound</a> | 
<a id="e_ld" href="#Lighting" class="panel">Lighting & Staging</a> | 

</div>

<div><img id="e_em" src="images/eventmanage.png" width="1037" height="480" /></div>
<div><img id="e_v" src="images/video.png" width="1128" height="480" /></div>
<div><img id="e_s" src="images/sound.png" width="1011" height="480" /></div>
<div><img id="e_l" src="images/light.png" width="1011" height="480" /></div>
$('#other').click(function() {
  $('#target').click();
});

http://api.jquery.com/click/ http://api.jquery.com/click/

just have all those other click function call the first one or assign them all a class 只需让所有其他click函数调用第一个或为他们分配一个类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM