我得到了一个外部样式表(.css文件),不会以任何方式改变.但是,我需要将此样式表应用于单个div,因此我已经存在的网页中的div的内容.我目前正在将样式表的内容作为文本读入我需要影响的div中的空白样式标记(使用.innerHTML)但这仍然影响整个网页而不仅仅是单个div.有人可以帮忙吗?
目前我有以下但它不太喜欢我:
1.index.php:
<!DOCTYPE html>
<html>
<body>
<div id = "bookList">
<?php
include("list.php");
?>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
2. list.php:
<?php
echo '<button id = "read">Read</button><br><br>';
echo
"<script type=\"text/javascript\">
$(\"#read\").click(function()
{
alert(\"<?php display(); ?>\");
});
</script>";
function display()
{
echo "hello";
}
?>
Run Code Online (Sandbox Code Playgroud)
从我上面发布的代码中可以明显看出,我试图使用php创建一个按钮,当点击它时将依次调用php函数.我还没有成功.任何建议将不胜感激,但我希望我的代码尽可能接近我现有的代码.