我很高兴阅读有关使用切换来单击并显示以及单击和隐藏文本的帖子(如何使用 javascript 在显示隐藏上更改切换文本),但后来我无法使代码正常工作。当我单击带下划线的超链接时,没有显示任何文本。
In function.php:
add_action('wp_enqueue_scripts', 'my_scripts_method');
function my_scripts_method() {
wp_enqueue_script('SHOWME',get_template_directory_uri() . '/admin/wp-
includes/js/jquery/SHOWME.js');
}
In ftp drive:
jQuery(document).ready(function($)
{
$(function showme(id)) {
var divid = $(document.getElementById(id));
$(if (divid.style.display == 'block') divid.style.display = 'none');
$(else divid.style.display = 'block');
}
array('jquery')
);
}
});
HTML in page:
<a onclick="SHOWME('list');" href="#"><h3>Air Barrier Association of America (ABAA)
Certification Training</h3>
</a>
<div class="showMe" style="display: none;">This is a widget</div>
<div class="showMe" style="display: none;">This is a widget</div>
<div class="showMe" style="display: none;">Self Adhered & Fluid Applied Installer
Training</div>