使用 javascript (facebox) 编辑已经制作的 html

发布于 2024-10-05 07:53:59 字数 2150 浏览 0 评论 0原文

我正在使用facebox(你可能知道它),我的脚本看起来像

$.extend($.facebox, {
    settings: {
      opacity      : 0,
      overlay      : true,
      loadingImage : 'http://example.com/images/loading.gif',
      closeImage   : 'http://example.com/images/closelabel.gif',
      imageTypes   : [ 'png', 'jpg', 'jpeg', 'gif' ],
      faceboxHtml  : '\
    <div id="facebox" style="display:none;"> \
      <div class="popup"> \
        <table> \
          <tbody> \
            <tr> \
              <td class="tl"/><td class="b"/><td class="tr"/> \
            </tr> \
            <tr> \
              <td class="b"/> \
              <td class="body"> \
                <div class="content"> \
                </div> \
                <div id="footer"> \
                <p class="left" id="changable"> \
                Footer \
                </p> \
                <p class="right"> \
                  <a href="#" class="close"> \
                    <img src="http://example.com/images/closelabel.gif" title="close" class="close_image" /> \
                  </a> \
                </p> \
                </div> \
              </td> \
              <td class="b"/> \
            </tr> \
            <tr> \
              <td class="bl"/><td class="b"/><td class="br"/> \
            </tr> \
          </tbody> \
        </table> \
      </div> \
    </div>'
    },

在文件中,即使用文本 (远程 html)我想根据文件更改页脚。将打开多个remote.html 文件(share.php、warning.php),我想根据这些文件更改页脚。我可以在这个 javascript 中做些什么,或者我可以在 share.php 和 warning.php 中做些什么来获取并将其内容设置为新内容吗?

我尝试过:(

$(function() {
        $("#changable").html('Hello');

    });  
$(function() {
        $("#changable").innerHTML = 'Hello';

    }); 
$(function() {
        $("#changable").text('Hello');

    }); 
$(function() {
        $(".left").html('Hello');

    }); 

我安装了jquery)但什么也没有。

我是 javascript 的新手,我知道这可能很容易,但我无法让它在我的一生中发挥作用。

提前致谢。

I am using facebox (you may know of it) and my script looks like

$.extend($.facebox, {
    settings: {
      opacity      : 0,
      overlay      : true,
      loadingImage : 'http://example.com/images/loading.gif',
      closeImage   : 'http://example.com/images/closelabel.gif',
      imageTypes   : [ 'png', 'jpg', 'jpeg', 'gif' ],
      faceboxHtml  : '\
    <div id="facebox" style="display:none;"> \
      <div class="popup"> \
        <table> \
          <tbody> \
            <tr> \
              <td class="tl"/><td class="b"/><td class="tr"/> \
            </tr> \
            <tr> \
              <td class="b"/> \
              <td class="body"> \
                <div class="content"> \
                </div> \
                <div id="footer"> \
                <p class="left" id="changable"> \
                Footer \
                </p> \
                <p class="right"> \
                  <a href="#" class="close"> \
                    <img src="http://example.com/images/closelabel.gif" title="close" class="close_image" /> \
                  </a> \
                </p> \
                </div> \
              </td> \
              <td class="b"/> \
            </tr> \
            <tr> \
              <td class="bl"/><td class="b"/><td class="br"/> \
            </tr> \
          </tbody> \
        </table> \
      </div> \
    </div>'
    },

and in the file, that is using text
(remote html) I want to change the footer depending on the file. Multiple remote.html files will be open (share.php, warning.php) and I want to change the footer depending on those. Is there something I can do in this javascript, or is there something I can do within each of share.php and warning.php to grab the and set it's content to something new?

I tried:

$(function() {
        $("#changable").html('Hello');

    });  
$(function() {
        $("#changable").innerHTML = 'Hello';

    }); 
$(function() {
        $("#changable").text('Hello');

    }); 
$(function() {
        $(".left").html('Hello');

    }); 

(I have jquery installed) but nothing.

I'm new to javascript, and I know this is probably easy, but I can't get it working for the life of me.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寻梦旅人 2024-10-12 07:53:59

Jquery 解决方案试试这个...

$(function() {
//a tag id is anchor_id
//p tag id is para_id        
$("#para_id").html($('#anchor_id').attr('title'));

});  

使用代码

$("#para_id").html($('#anchor_id').attr('title'));

By trigerring an event. My sample code is here...

$("#button_id").click(function(){
$("#para_id").html($('#anchor_id').attr('title'));
});

Jquery solution Try this...

$(function() {
//a tag id is anchor_id
//p tag id is para_id        
$("#para_id").html($('#anchor_id').attr('title'));

});  

Use the code

$("#para_id").html($('#anchor_id').attr('title'));

By trigerring an event. My sample code is here...

$("#button_id").click(function(){
$("#para_id").html($('#anchor_id').attr('title'));
});
寒尘 2024-10-12 07:53:59

我只需

<div id="footer">

    <p class="left" id="changable">
        Share This
    </p> 

    <p class="right"> 
        <a href="#" class="close"> 
            <img src="http://example.com/images/closelabel.gif" title="close" class="close_image" />  
        </a>                 
    </p> 

</div> 

在每个远程文件中添加:即可使其正常工作。然而,由于我用不同的方式解决了这个问题,我将@mohan ram 标记为正确。

I got it working by just adding:

<div id="footer">

    <p class="left" id="changable">
        Share This
    </p> 

    <p class="right"> 
        <a href="#" class="close"> 
            <img src="http://example.com/images/closelabel.gif" title="close" class="close_image" />  
        </a>                 
    </p> 

</div> 

to each of the remote files. However, since I solved it a different way, I marked @mohan ram as right.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文