1

每次我点击一个帖子链接时,我都希望帖子的标题出现在标题页面上。看屏幕截图在此处输入图像描述

正如所见,我希望用帖子标题取代“虔诚的信息”......

HTML 代码:

<div id="devotionpost" data-role="page">
        <div data-role="header" data-position="fixed" data-theme="a">
            <h1>Devotional Message</h1>
            <a href="#devotion" data-icon="back" data-iconpos="notext">Devotion</a>
        </div><!-- header-->
        <div data-role="content">
            <div id="mypost"> </div>
        </div><!-- content -->
    </div><!-- page -->

JS代码:

function showPost(id) {
    $.getJSON('http://howtodeployit.com/?json=get_post&post_id=' + id + '&callback=?', function(data) {
        var output='';
        output += '<h3>' + data.post.title + '</h3>';
        output += data.post.content;
        $('#mypost').html(output);
    }); 
4

1 回答 1

2
function showPost(id) {
$("#devotionpost h1").html("");// to empty previous title

    $.getJSON('http://howtodeployit.com/?json=get_post&post_id=' + id + '&callback=?', function(data) {
        var output='';
        output += '<h3>' + data.post.title + '</h3>';
        output += data.post.content;
        $('#mypost').html(output);

$("#devotionpost h1").html(data.post.title);// by this 'Devotional Message' replaced by the Post Title..

    });
于 2013-10-14T07:28:22.833 回答