我被卡住了。。。
我在WP页面中有一个短代码。shortcode中的PHP函数执行以下逻辑:
if (isset($_GET[\'some_id\'])) { // Get single item
Query MySQL table to get the item with the id=\'some_id\'
// Show item
$html .= \'Some html\';
$html .= \'<div id="div_id">blabla</div>\'; // <-- Here is the problem zone
return $html;
// All of the above works perfectly
}
else { // Show list of items
Query MySQL table to get list of items
//Show list
foreach ($results as $result)
$html .= $result->titel.\' <a href="\'.esc_url( add_query_arg( \'some_id\', $result->id, \'The URL of the current page\' ) ).\'">Get details</a>\';
return $html;
}
这段代码完成了它应该做的事情:页面首先显示项目列表(未设置b/c URL参数some\\u id)。然后,在列表中,我单击“获取详细信息”。完全相同的页面重新加载(现在设置了参数“some\\u id”),我在某处获得了相应的输出,其中包含div id=“blabla”。
然而,我希望页面随后直接滚动到div id=“blabla”,但我无法实现这一点。我尝试了javascript、jquery,还将#blablabla放在URL中(URL/?some\\u id=3#blabla)。。。什么都不管用。。。
非常感谢任何提示/指示。非常感谢。拉里
抱歉,这是一个愚蠢的javascript错误。。。。请原谅打扰。