简体   繁体   English

如何使用jquery点击功能后刷新div?

[英]how do i refresh the div after a click function using jquery?

im trying to refresh a div on the page using jquery after a click function: 我试图在点击功能后使用jquery刷新页面上的div:

$('.finishTag').live('click', function() {
           $('#Qtopics').hide();
            //refresh #hiddenTopic here im stuck here :))
           $('#hiddenTopic').show();

            });

EDIT: 编辑:

i mean refresh the div once!! 我的意思是刷新div一次!! and then show it because its hidden at this point!!! 然后显示它,因为它隐藏在这一点!

<div id="hiddentTopic">
 <?php

       while ($Qtopic = mysql_fetch_array($getTopics)){
         echo "<a href='google.com' class='topicBullet'>".$Qtopic['name']."</a>";
             }
?>
       </div>

use load 使用load

$('#hiddenTopic').load("server.php");

check your id that is with t 检查你的身份是否与t

hiddentTopic

please change it 请改变它

hiddenTopic

like this 像这样

working demo 工作演示

http://jsfiddle.net/JLyay/1/ http://jsfiddle.net/JLyay/1/

and this is not a refresh this is called hide and show 这不是刷新,这称为hide and show

If I understood it right, you wanna reload content, generated by php part. 如果我理解正确,你想重新加载由php部分生成的内容。 It's impossible because php is a server-side part while javascript - client-side. 这是不可能的,因为php是服务器端的部分,而javascript - 客户端。 What you neeed is to make file server.php , move php part there and then use $('#hiddenTopic').load("server.php"); 你需要的是制作文件server.php ,在那里移动php部分然后使用$('#hiddenTopic').load("server.php"); As @gowri said before. 正如@gowri之前说过的那样。

IF you want to change the formating of div you can do that using any css class like this: $('divId').addClass('class_name'); 如果你想改变div的格式化你可以使用任何css类来做到这一点:$('divId')。addClass('class_name');

to add data you can pick the div using divid and update its innet paragraph aur heading text like this: 要添加数据,您可以使用divid选择div并更新其innet段aur标题文本,如下所示:

$('div1 p').html(' blah blah any text … '); $('div1 p')。html(' blah blah any text ...'); $('h2').text(' blah blah blah blah …'); $('h2')。text(' blah blah blah blah blah ...');

$(' START! ').prependTo('#divID'); $(' START! ')。prependTo('#divID'); (it write START before div) $(' END! ').appendTo('#divID'); (它在div之前写START)$(' END! ')。appendTo('#divID'); (it write END after div) (在div之后写END)

hope this ll help you. 希望这会帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM