douwei3863 2015-03-29 09:44
浏览 54

将外部jQuery和CSS文件嵌入到index.php文件中

I have a specific question. How do I embed external .js or .css file in a php file extension?

It does not work the way I embed it in html file extension.

  • 写回答

1条回答 默认 最新

  • dongshi7350 2015-03-29 09:55
    关注

    You would usually include these inside the <head> tags

    <link rel="stylesheet" type="text/css" href="myStyles.css">
    <script src="myScript.js"></script>
    

    But if you must use php for whatever reason, you can use

    <? include "myScript.php"; ?>
    

    EDIT:

    In response to your comment about targeting outputted text, you would simply echo the text between an identifiable tag. Eg:

    <span id:="targetThis">
        <? echo "Text" ?>
    </span>
    

    Now you can target the text in Css using:

    #targetThis {
        color: red;
    }
    

    You can also grab it using JQuery using:

    $('#targetThis') then do whatever it is you wanted to do with it...
    

    Eg

    $('#targetThis').html('Edited Text');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制