Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery slideonlyone函数_Javascript_Jquery - Fatal编程技术网

Javascript jquery slideonlyone函数

Javascript jquery slideonlyone函数,javascript,jquery,Javascript,Jquery,我目前正在使用jqueryslideonye函数。单击时,我在实现扩展/折叠图像(Plus.png)(减去.png)更改时遇到问题。这是我的jquery代码 <script type="text/javascript"> function slideonlyone(thechosenone) { $('div[name|="newboxes2"]').each(function(index) { if ($(this).attr("id") == thechosenon

我目前正在使用jqueryslideonye函数。单击时,我在实现扩展/折叠图像(Plus.png)(减去.png)更改时遇到问题。这是我的jquery代码

<script type="text/javascript">
function slideonlyone(thechosenone) {
 $('div[name|="newboxes2"]').each(function(index) {
      if ($(this).attr("id") == thechosenone) {
           $(this).find("img").attr({src:"Minus.png"}).slideDown(200);
      }
      else {
           $(this).find("img").attr({src:"Plus.png"}).slideUp(600);
      }
 });
}</script>


<table><tr>
  <td>
     <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px;">
        <a id="myHeader1" href="javascript:slideonlyone('newboxes1');" ><img src="images/faq_cuts/Plus_Circle.png";/>slide this one only</a>
     </div>
     <div name="newboxes2" id="newboxes1" style="border: 1px solid black; background-color: #CCCCCC; display: block;padding: 5px;">Div #1</div>
  </td>
  <td>
     <div style="border: 1px solid blue; background-color: #99CCFF; padding: 5px;">
        <a id="myHeader2" href="javascript:slideonlyone('newboxes2');" ><img src="images/faq_cuts/Plus_Circle.png";/>slide this one only</a>
     </div>

功能幻灯片一(氯乙烯酮){
$('div[name |='newboxes2'])。每个(函数(索引){
if($(this.attr(“id”)==氯乙烯酮){
$(this.find(“img”).attr({src:'Minus.png}).slideDown(200);
}
否则{
$(this.find(“img”).attr({src:.Plus.png}).slideUp(600);
}
});
}
第1分部

您的html中实际上没有任何图像


此外,您正在错误地使用
attr
。如果您想设置图像的
src
,它应该是
.attr(“src”,“减号.png”)

您的html中实际上没有任何图像


此外,您正在错误地使用
attr
。如果你想设置图像的
src
,它应该是
.attr(“src”,“减号.png”)

好的,伙计,我试过了,但没有成功<代码>函数slideonone(thechosenone){$('div[name |=“newboxes2”]')。每个函数(index){if($(this).attr(“id”)==thechosenone{$(this).查找(“img”)attr({“src”,“images/faq_cuts/Minus_Circle.png”)。滑动下(200)}其他{$(this).查找(“img”).attr”(“src”,“images/faq_cuts/Plus_Circle.png”)。slideUp(600); } }); } 是的,我知道这一点。你能告诉我那些语法在哪里吗?我对JQueryArright mate非常熟悉,我试过了,但没有成功<代码>函数slideonone(thechosenone){$('div[name |=“newboxes2”]')。每个函数(index){if($(this).attr(“id”)==thechosenone{$(this).查找(“img”)attr({“src”,“images/faq_cuts/Minus_Circle.png”)。滑动下(200)}其他{$(this).查找(“img”).attr”(“src”,“images/faq_cuts/Plus_Circle.png”)。slideUp(600); } }); } 是的,我知道这一点。你能告诉我那些语法在哪里吗?我是jquery的新手