为什么我收到此错误:
未捕获的TypeError:无法读取未定义的属性'scrollHeight'.
"阅读更多"按钮将我返回到页面顶部,而不是更改<div>元素的高度.我该如何解决?
这是我的代码:
function piki( $atts, $content = null ) {
{ ?>
<script type="text/javascript">
var h = jQuery('#piki')[0].scrollHeight;
jQuery('#more').click(function(e) {
e.stopPropagation();
jQuery('#piki').animate({
'height': h
})
});
jQuery(document).click(function() {
jQuery('#piki').animate({
'height': '50px'
})
})
</script>
<?php }
$url = '/?s=';
$str = '';
$output = array();
$count = 0;
foreach (explode(", ",$content) as $content) {
$count++;
$output[] = "<a href='" . $url . $content . "'>" . $content . "</a>";
if ($count == 50) {
break;
} …Run Code Online (Sandbox Code Playgroud)