doukun0888 2013-12-14 10:42
浏览 27

jquery不适用于每个href元素

  1. when first "read more" href click, div changed.first click it span and when second click it shrink.
  2. But it is not work for other href element
  3. how to solve this problem.please help me.

     <script>
         $(document).ready(function(){
             $('#more').click(function(){
                var toggleheight = $("#readmore").height() == 500 ? "100px" : "500px";
                      $('#readmore').animate({ height: toggleheight });
                      });
               });
    
         </script>
    
  4. here is the php code

         <?php
          mysql_query("SET NAMES 'utf8'");
          $set_news=mysql_query("SELECT solution_date,Category,solution FROM solution ORDER BY solution_date DESC LIMIT 10",$connection);
            if(!$set_news){
            die("database query failed".mysql_error()); 
                            }
    
                            for($i=1;$i<=10;$i++) {
                            $rowofnews=mysql_fetch_array($set_news);
    
                            $category=$rowofnews['Category'];
                            $solution=$rowofnews['solution'];
    
                            echo ('<li>');
                            echo ('<div id="readmore"');
                            echo('<h2>');
                            echo $category;
                            echo('</h2><p>');
                            echo $solution;
                            echo('</p></div>');
                            echo('<p><span><a href="#" class="more" id="more">Read More</a></span></p></li>');
                            }
            ?>
    
  • 写回答

2条回答 默认 最新

  • duangang1991 2013-12-14 10:45
    关注

    If you're trying to select multiple elements, you shouldn't use ID's, you should select by class, like this:

    $('.more').on("click", function(){
    
    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用