Onclick仅刷新div [英] Onclick refresh only div

查看:68
本文介绍了Onclick仅刷新div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我需要有关刷新div的帮助,但不需要自动刷新!

Hi i need help with refreshing div, but not auto refresh!

我的div是这样的.

<div id="osvezi">
<?php include('moduli/skupina_artiklov/osvezi.php'); ?>
</div>

我希望我单击一些按钮,以便他们仅使div osvezi刷新.

I want that i clicked some button they refreshed me only div osvezi.

感谢您的帮助.

推荐答案

您可以使用 .load() 使用这样的选择器:

You can use .load() with a selector like this:

$(function() {       //run when the document's ready, elements are loaded
  $("#myButton").click(function() {
    $("#osvezi").load(location.href + " #osvezi > *");
  });
});

这将响应单击id="mybutton"的元素,并仅重新提取页面.另外,如果可以直接访问moduli/skupina_artiklov/osvezi.php,则可以直接加载它(更有效!):

This responds to an element with id="mybutton" being clicked and refetches the page but only that portion. Alternatively, if moduli/skupina_artiklov/osvezi.php is accessible directly, you can just load that directly (more efficient!) this:

$(function() {
  $("#myButton").click(function() {
    $("#osvezi").load("moduli/skupina_artiklov/osvezi.php");
  });
});

这篇关于Onclick仅刷新div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆