如何在表中创建Read More按钮
How I create a Read More button inside a table?
<?php $counter = 0 ?>
<table>
<?php foreach($attributes as $a): ?>
<tr>
<td><?php $a['name']?></td>
<td><?php $a['Price']?></td>
</tr>
<?php $counter++;
if ($counter > 3) ?> <!-- What to do here? -->
<?php endforeach; ?>
</table>
在这样的PHP块中,我想在三个tr元素之后获得一个阅读更多按钮,当我单击按钮时显示所有其余的元素…
跟PHP有关吗?
不,它与php无关。如果你不想重载整个页面,你需要JavaScript来实现它。
在PHP中,您可以将短版本和长版本打印到单独的div
中,然后在View-More-Button上使用以下JS-Code:
document.getElementById("shortId").style.display = "none";
document.getElementById("longId").style.display = "block";
相关文章:
- nodejs does not read JSON
- jquery ajax post to .aspx page load - how to read variable p
- JSonStore Error with d.read
- websocket javascript read write
- javascript firstChild, nextSibling read-only
- Read an MVC @Html.TextBoxFor from Javascript
- Jquery read xml block
- read完全没有用Java Nashorn Javascript引擎定义
- php doesnt read jquery indexOf?
- Intel Edison: MRAA javascript i2c.read() 将结果存储为对象或字符串
- openlayers geojson read as wkt
- Ajax to read PHP
- XMLHttpRequest ::ERR_CONNECTION_RESET 同时上传大型(2 Mo & More
- 带有 ng-repeat、ng-show “show more” 和延迟加载的角度指令
- GetElementby More Item
- Bootstrap javascript at very end and jQuery $(document).read
- 如何在表中创建Read More按钮
- 如何修改这个read more js
- Rails truncate with a 'read more' toggle
- BX Slider可通过Read More按钮调整自适应高度