第 API 组产生一个 DIV
Group API results in one DIV
我真的很难尝试编辑 JS code/API(Google 提要)以使其在响应式设计中工作。
现在API的结果如下:
<div class="gfg-subtitle"></div>
<div class="gfg-list"></div>
<div class="gfg-subtitle"></div>
<div class="gfg-list"></div>
...
我希望它是那样的:
<div class="gfg-group">
<div class="gfg-subtitle"></div>
<div class="gfg-list"></div>
</div>
<div class="gfg-group">
<div class="gfg-subtitle"></div>
<div class="gfg-list"></div>
</div>
我试过了(但没有得到任何结果):
$(document).ready(function(){ $("#contentfeed").append("<div class='gfg-grouped'></div>");
$(".gfg-grouped").text($(".gfg-subtitle").text() + " " +$(".gfg-list").text()); });
这个也试过了(好像也不行):
var groupDiv = document.createElement('div');
groupDiv.className = 'gfg-group';
groupDiv.appendChild(newTitle);
groupDiv.appendChild(newList);
有很多逻辑,我对 API 不熟悉,但您可以像这样对条目进行分组:
// group the Title and List
var groupDiv = document.createElement('div');
groupDiv.className = 'gfg-grouped';
groupDiv.appendChild(newTitle);
groupDiv.appendChild(newList);
你会得到如下内容:
$intendedContainer = $("");
$(".gfg-subtitle").each(function(){
var $list = $(this).next().detach();
var $subitle = $(this).detach();
var $groupItem = $("<div class='gfg-group'></div>");
$groupItem.append($list).append($subtitle);
$groupItem.insertBefore($subTitle);
$intendedContainer.append($groupItem);
});
我没有完成你的整个代码,因为它非常庞大,但这是你需要实现的逻辑。
感谢之前的回复,我继续自己解决了它(花了我太长时间,但这就是我们所有人学习的方式,对吗?:) 如果可以帮助某人,请将解决方案留在这里。
我添加了以下几行:
var newGroup = this.createDiv_('gfg-grouped');
和
if (!this.options.horizontal && this.options.stacked) {
var newGroup = this.createDiv_('gfg-grouped');
var newTitle = this.createDiv_('gfg-subtitle');
nodes.root.appendChild(newGroup);
newGroup.appendChild(newTitle);
this.setTitle_(this.results[0].feed, newTitle);
和
newGroup.appendChild(nodes.list);
我真的很难尝试编辑 JS code/API(Google 提要)以使其在响应式设计中工作。
现在API的结果如下:
<div class="gfg-subtitle"></div>
<div class="gfg-list"></div>
<div class="gfg-subtitle"></div>
<div class="gfg-list"></div>
...
我希望它是那样的:
<div class="gfg-group">
<div class="gfg-subtitle"></div>
<div class="gfg-list"></div>
</div>
<div class="gfg-group">
<div class="gfg-subtitle"></div>
<div class="gfg-list"></div>
</div>
我试过了(但没有得到任何结果):
$(document).ready(function(){ $("#contentfeed").append("<div class='gfg-grouped'></div>");
$(".gfg-grouped").text($(".gfg-subtitle").text() + " " +$(".gfg-list").text()); });
这个也试过了(好像也不行):
var groupDiv = document.createElement('div');
groupDiv.className = 'gfg-group';
groupDiv.appendChild(newTitle);
groupDiv.appendChild(newList);
有很多逻辑,我对 API 不熟悉,但您可以像这样对条目进行分组:
// group the Title and List
var groupDiv = document.createElement('div');
groupDiv.className = 'gfg-grouped';
groupDiv.appendChild(newTitle);
groupDiv.appendChild(newList);
你会得到如下内容:
$intendedContainer = $("");
$(".gfg-subtitle").each(function(){
var $list = $(this).next().detach();
var $subitle = $(this).detach();
var $groupItem = $("<div class='gfg-group'></div>");
$groupItem.append($list).append($subtitle);
$groupItem.insertBefore($subTitle);
$intendedContainer.append($groupItem);
});
我没有完成你的整个代码,因为它非常庞大,但这是你需要实现的逻辑。
感谢之前的回复,我继续自己解决了它(花了我太长时间,但这就是我们所有人学习的方式,对吗?:) 如果可以帮助某人,请将解决方案留在这里。
我添加了以下几行:
var newGroup = this.createDiv_('gfg-grouped');
和
if (!this.options.horizontal && this.options.stacked) {
var newGroup = this.createDiv_('gfg-grouped');
var newTitle = this.createDiv_('gfg-subtitle');
nodes.root.appendChild(newGroup);
newGroup.appendChild(newTitle);
this.setTitle_(this.results[0].feed, newTitle);
和
newGroup.appendChild(nodes.list);