【问题标题】:how to refresh the particular div while click image单击图像时如何刷新特定的div
【发布时间】:2017-05-15 09:22:18
【问题描述】:

我想使用图像 onclick 刷新 div。这里我有图像,该图像 id 是“sellhide”,还有一个 div id 是“sellChart”。 代码:

<div class="col-xs-12 col-lg-6 col-sm-6 col-md-6 index_table_three" id="sellChart">
                        <div class="row" id="title">
                            <div class="col-xs-6 col-sm-6 col-lg-6 col-md-6" id="">
                                {{ Form::open(array('url' => 'lookup/be-check', 'enctype' => 'multipart/form-data', 'class' => 'form-inline', 'id' => 'sellChartForm')) }}                                    
                                {{ Form::select('date_time', array($end_date.';'.$today => 'today', $lastWeek.';'.$today => 'Last 7 days', $lastMonth.';'.$today => 'One Month', '' => 'Custom Range'), $end_date.';'.$today, array('id' => 'date_time', 'onchange' => 'GetChangeDate()')) }}
                                {{ Form::Submit('Apply', array('id' => 'getSellRange', 'class' => 'getSellRange'))}}
                                {{ Form::close() }}
                            </div>
                            <div class="col-xs-4 col-sm-4 col-lg-4 col-md-4" id="">
                                <h4>Sell property lists</h4>
                            </div>
                            <div class="col-xs-2 col-sm-2 col-lg-2 col-md-2" id="">
                                <img src="<?php echo SITE_PATH . '/mb-images/reset.png' ?>" width="35px;" height="35px;" class="img-responsive center-block" id="sellhide" />
                            </div>
                        </div>
                        <div class="row" id="sellDrawChart">
                            <h5 style="margin-right:70%;"><b>Property type</b></h5>
                            <canvas id="sellCanvas" ></canvas>
                            <h6 style="margin-top:0px;margin-left:80%;"><b>No of property count</b></h6>
                        </div>
                    </div>

脚本:

$(function() { 
      $( '#sellhide' ).on( 'click', function() { 
             $('#sellChart').html(); 
      }); 
 });   

我尝试了很多方法它不接受脚本。

【问题讨论】:

  • 你的问题不清楚。
  • 您是否尝试过在单击事件上调用 ajax 并在响应 ajax 调用时更改 HTML 从而更改 div?
  • $('#sellChart').html();将只返回现有的 HTML。
  • @JaydeepPandya 在一个 div 中我有一些功能。上面我有图像,同时单击图像我想重新加载整个 div ya
  • 这是错误的 $("#rentChart").html();您需要将其替换为 ajax 数据,例如 => $("#rentChart").html(data);

标签: javascript php jquery css ajax


【解决方案1】:

使用 jQuery get() 方法: https://api.jquery.com/jquery.get/

例如:

$.get( "ajax/test.html", function( data ) {
  $( ".result" ).html( data );
  alert( "Load was performed." );
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 2016-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多