jquery 各个iframe中查找元素的问题
主页是这样的<tablecellspacing="0"cellpadding="0"width="100%"border="0"style="background:#EE...
主页是这样的
<table cellspacing="0" cellpadding="0" width="100%" border="0" style="background: #EEF2FB" id="maintable" height="100%">
<tr>
<td>
<div style="height:100%;overflow:hidden;">
<iframe class="left_iframe" id="frmleft" name="left" src="/index.php/index/left" scrolling="no"
frameborder="0" allowtransparency></iframe>
</div>
</td>
<td width="100%" id="frametd" height="100%">
<iframe class="main_iframe" id="mainframe" title="后台首页" name="main" src="/index.php/index/main"
scrolling="auto" frameborder="0" allowtransparency></iframe>
</td>
</tr>
</table>
left_iframe 只有:
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav"><li><a href="/template" target="maininfo">前端页面管理</a></li></ul>
</div>
main_iframe:
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a data-toggle="tab" href="#home">Home</a></li>
</ul>
怎么用jquery 从left_iframe中点击li然后往main_ifram中添加li? 展开
<table cellspacing="0" cellpadding="0" width="100%" border="0" style="background: #EEF2FB" id="maintable" height="100%">
<tr>
<td>
<div style="height:100%;overflow:hidden;">
<iframe class="left_iframe" id="frmleft" name="left" src="/index.php/index/left" scrolling="no"
frameborder="0" allowtransparency></iframe>
</div>
</td>
<td width="100%" id="frametd" height="100%">
<iframe class="main_iframe" id="mainframe" title="后台首页" name="main" src="/index.php/index/main"
scrolling="auto" frameborder="0" allowtransparency></iframe>
</td>
</tr>
</table>
left_iframe 只有:
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav"><li><a href="/template" target="maininfo">前端页面管理</a></li></ul>
</div>
main_iframe:
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a data-toggle="tab" href="#home">Home</a></li>
</ul>
怎么用jquery 从left_iframe中点击li然后往main_ifram中添加li? 展开
展开全部
$(window).on('load', function () {
$('#frmleft').contents().find('.nav a').click(function (e) {
$('#mainframe').contents().find('#myTab').append('<li>' + this.parentNode.innerHTML + '</li>');
e.preventDefault();
});
});
追问
!!我就是想这样,,不过innerhtml不太懂,如果我想给新增的a标签添加个data-toggle="tab"属性,该怎么改?
追答
$(window).on('load', function () {
$('#frmleft').contents().find('.nav a').click(function (e) {
$('#mainframe').contents().find('#myTab').append('<li>' + this.parentNode.innerHTML + '</li>').find('a').attr('data-toggle', 'tab');
e.preventDefault();
});
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询