javascript - 如何在单击图像时刷新特定的 div

标签 javascript php jquery css ajax

我想使用图像 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(); 
      }); 
 });   

我试了很多方法都不接受这个脚本。

最佳答案

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

例如:

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

关于javascript - 如何在单击图像时刷新特定的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41407006/

相关文章:

javascript - 如何在 javascript 中循环遍历 JSON 关联数组?

javascript - 通过父组件上的方法动态绑定(bind)vue js中的类

javascript - 基于网格列值的 Kendo UI 网格编辑器

php - HTTP 缓存、用户身份验证和 PHP

php - 使用正则表达式替换 smarty 模板系统?

Jquery 动画属性?

javascript - jQuery Accordion 链接不起作用

javascript - 如何在用户滚动到它们之前加载 onScroll 背景图像?

php - 在PHP中删除JSON数组元素,然后重新编码为JSON

javascript - 使用 Javascript 解析 HTML 字符串以获取元素内容