PHP 获取文件路径
dirname(FILE)
PHP scandir() 函数
scandir() 函数返回一个数组,其中包含指定路径中的文件和目录。 若成功,则返回一个数组,若失败,则返回 false。如果 directory 不是目录,则返回布尔值 false 并生成一条 E_WARNING 级的错误。 scandir(directory,sort,context) 参数 描述 directory 必需。规定要扫描的目录。 sort 可选。规定排列顺序。默认是 0 (升序)。如果是 1,则为降序。 context 可选。规定目录句柄的环境。context 是可修改目录流的行为的一套选项。 例子 <?php print_r(scandir("images")); ?> 输出: Array ( [0] => . [1] => .. [2] => dog.jpg [3] => house.jpg [4] => logo.gif )
jQuery 属性操作 - removeClass() 方法
$(selector).removeClass(class) 示例1: [pcsh lang=”js” tab_size=”4” message=”” hl_lines=”” provider=”manual”] $("button").click(function(){ $("p:first").removeClass("intro"); }); [/pcsh] $(selector).removeClass(function(index,oldclass)) 示例2: 参数 描述 function(index,oldclass) 必需。通过运行函数来移除指定的类。 index - 可选。接受选择器的 index 位置。 html - 可选。接受选择器的旧的类值。
wordpress get_the_title 和 the_title函数
get_the_title 和 the_title 两个函数用来在文章页面显示文章标题的函数, the_title 默认直接显示,get_the_title 默认返回字符串 [pcsh lang=”php” tab_size=”4” message=”” hl_lines=”” provider=”manual”] <?php the_title( $before, $after, $echo ); ?> [/pcsh] $before标题前的字符 $after标题后的字符 $echo显示、还是返回字符串,默认为true [pcsh lang="php" tab_size="4" message="" hl_lines="" provider="manual"] <?php $myTitle = get_the_title($ID); ?> [/pcsh]
jQuery 属性操作 - addClass() 方法
实例 向第一个 p 元素添加一个类: [pcsh lang=”js” tab_size=”4” message=”” hl_lines=”” provider=”manual”] $("button").click(function(){ $("p:first").addClass("intro"); }); [/pcsh] 使用函数来添加类 使用函数向被选元素添加类。 语法 [pcsh lang="js" tab_size="4" message="" hl_lines="" provider="manual"] $(selector).addClass(function(index,oldclass)) [/pcsh] function(index,oldclass) 必需。规定返回一个或多个待添加类名的函数。 index - 可选。选择器的 index 位置。 class - 可选。选择器的旧的类名。
使用wordpress内置的admin-ajax.php实现ajax功能
这里一个特殊的地方是执行的hook名,执行的hook的名字是与post过来的数据有关的,如下面do_action所示 这个文件是 WordPress 内置用来进行 Ajax 读取的文件,本来是用于后台的,但是前台我们也可以拿来用。 用这个文件进行 Ajax 的好处主要有几点: 安全,WordPress 本身进行了很复杂的安全性优化,如果我们都自己写是很浪费时间和资源的。兼容,由于文件是公用的,提供了通用的钩子,其它插件都可以参与进去。高效,这个不解释了,既符合原则(执行到了 init 钩子),又兼顾了效率问题。方便,一个钩子即可输出代码,都不用判断条件。基本就这几点了,网上查了一下,发现关于此文件的资料并不多,于是看了下源码,发现使用其实很简单。 首先请求这个文件: [pcsh lang=”php” tab_size=”4” message=”” hl_lines=”” provider=”manual”] echo admin_url( 'admin-ajax.php' ); [/pcsh] 向ad...
jquery获取窗口高度
[pcsh lang=”js” tab_size=”4” message=”” hl_lines=”” provider=”manual”] alert($(window).height()); //浏览器窗口可视区域高度 alert($(document).height()); //浏览器当前窗口文档的高度 alert($(document.body).height());//浏览器当前窗口文档body的高度 alert($(document.body).outerHeight(true));//窗口body的总高度 包括border padding margin alert($(window).width()); //浏览器当前窗口可视区域宽度 alert($(document).width());//浏览器当前窗口文档对象宽度 alert($(document.body).width());//浏览器当前窗口文档body的高度 alert($(document.body).outerWidth(true));/...
js获取窗口高度
[pcsh lang=”js” tab_size=”4” message=”” hl_lines=”” provider=”manual”] var s = "网页可见区域宽 :"+ document.body.clientWidth; s += "\r\n网页可见区域高:"+ document.body.clientHeight; s += "\r\n网页可见区域高:"+ document.body.offsetHeight +" (包括边线的宽)"; s += "\r\n网页正文全文宽:"+ document.body.scrollWidth; s += "\r\n网页正文全文高:"+ document.body.scrollHeight; s += "\r\n网页被卷去的高:"+ document.body.scrollTop; s += "\r\n网页被卷去的左:"+ ...
jquery not函数用法@jquery删除一个或多个元素
示例 $(obj).siblings().not(“.clear,span”)
css absolute relative定位
absolute是绝对定位;而relative是相对定位;解释:绝对定位就是相对于父元素的定位,不受父元素内其他子元素的影响;而相对定位是相对于同级元素的定位,也就是上一个同级元素 static 默认值。没有定位,元素出现在正常的流中(忽略 top, bottom, left, right 或者 z-index 声明)。 fixed 生成绝对定位的元素,相对于浏览器窗口进行定位。 元素的位置通过 “left”, “top”, “right” 以及 “bottom” 属性进行规定。 inherit 规定应该从父元素继承 position 属性的值。