Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery动态更改html结构_Jquery_Html - Fatal编程技术网

Jquery动态更改html结构

Jquery动态更改html结构,jquery,html,Jquery,Html,我有一个html结构,比如- <div class="fullcalendar-event"> <h3 class="title"><a href="isv-events/test-event">Test Event</a></h3> 现在我想将页面加载时的html更改为 <div class="fullcalendar-event"> <span class="qtip-link"> <span

我有一个html结构,比如-

<div class="fullcalendar-event"> 
<h3 class="title"><a href="isv-events/test-event">Test Event</a></h3> 

现在我想将页面加载时的html更改为

<div class="fullcalendar-event">
<span class="qtip-link">
<span class="qtip-tooltip">
Header to appear in tooltip 
</span> 
<h3 class="title">
<a href="/saasmax/trunk/isv-events/test-event">Text to appear in tooltip</a></h3>
</span>

标题显示在工具提示中
关于我应该使用什么jQuery函数以及解决这个问题的方法,有什么想法吗

编辑的问题

完整数据的格式如下-

<div class="fullcalendar-event"> 
      <h3 class="title"><a href="/saasmax/trunk/isv-events/test-event">Test Event</a></h3> 
      <div class="fullcalendar-instance"> 
      <a href="/saasmax/trunk/isv-events/test-event" field="field_e_date" allDay="1" start="2011-04-25" end="2011-04-25" index="0" eid="184" entity_type="node" cn="fc-event-default isv_events node-type-isv_events" title="Test Event" class="fullcalendar-event-details" editable=""><span class="date-display-single">Mon, 04/25/2011</span></a>    </div> 
    </div> 

因此,如果您看到我想在第一个锚点标记(位于div fullcalendar内)上设置qtip

我需要的所有数据都是

要在工具提示中显示的标题应该是div fullcalendar实例中锚定的标题


工具提示中显示的文本可以是锚定标记中的链接。(这在两个div中都是相同的)

我已经根据您的更新编辑了我的答案。我不是说我完全理解您,但这段代码应该可以完成这项工作

$(document).ready(function() {
    //access to whole div
    var $fe=$('.fullcalendar-event');
    //access to H3
    var $fe_title=$('h3.title', $fe);
    //creating qtip-tooltip SPAN
    var $tooltip_span=$('<span class="qtip-tooltip" />')
                          .text($('.fullcalendar-instance a', $fe).attr('title'));
    //wrapping H3 in SPAN and adding tooltip before it
    $fe_title
        .wrap('<span class="qtip-link" />')
        .before($tooltip_span);

    /* I am unsure if you want to change HREF, uncomment if yes
    //access to the link in the H3
    var $fe_title_link=$('a', $fe_title);
    //creating new HREF
    var newhref='/saasmax/trunk/'+$fe_title_link.attr('href');
    //setting HREF for link
    $fe_title_link.attr('href', newhref);
    */
});
$(文档).ready(函数(){
//访问整个分区
var$fe=$('.fullcalendar事件');
//访问H3
变量$fe_title=$('h3.title',$fe);
//创建qtip工具提示范围
变量$tooltip_span=$(“”)
.text($('.fullcalendar实例a',$fe).attr('title');
//将H3包装在跨度中并在其前面添加工具提示
$fe_标题
.wrap(“”)
.before($tooltip_span);
/*我不确定您是否要更改HREF,如果是,请取消注释
//访问H3中的链接
变量$fe_title_link=$('a',$fe_title);
//创建新HREF
var newhref='/saasmax/trunk/'+$fe_title_link.attr('href');
//设置链接的HREF
$fe_title_link.attr('href',newhref);
*/
});

我还创建了一个,因此您可以看到它的发生,并在必要时对其进行调整。

您从何处获取数据?我指的是新元素的数据。它是常量吗?新数据的内容是动态的。我将编辑我的问题以告诉您需要获取的确切数据。首先尝试我在回答中给出的代码。尝试将其更改为您的具体需求。如果您仍然有问题,我很乐意提供帮助。您可以看一下编辑后的问题,并建议如何动态设置标题和数据。@ayush请尝试,如果需要,请说明您需要什么。