jQuery 遍历 - prevAll() 方法
prevAll函数的获取顺序: prevAll实际上是从 当前匹配元素 依次向上匹配的 如下实验 [pcsh lang=”php” tab_size=”4” message=”” hl_lines=”” provider=”manual”] <html> <head> <script type="text/javascript" src="/js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ (function(){ $("#ddd").prevAll("li").each(function(){ alert($(this).text()); }); })(); }); </script> </head> <body> &l...
jQuery - 获得内容和属性
获得内容 - text()、html() 以及 val() 三个简单实用的用于 DOM 操作的 jQuery 方法: text() - 设置或返回所选元素的文本内容 html() - 设置或返回所选元素的内容(包括 HTML 标记) val() - 设置或返回表单字段的值 下面的例子演示如何通过 jQuery text() 和 html() 方法来获得内容: 实例 $("#btn1").click(function(){ alert("Text: " + $("#test").text()); }); $("#btn2").click(function(){ alert("HTML: " + $("#test").html()); }); 获取属性 - attr() jQuery attr() 方法用于获取属性值。 下面的例子演示如何获得链接中 href 属性的值: 实例 $("button").click(function(){ alert($("#w3s").attr("href")); });
jQuery 遍历 - prev() 方法
prev() 获得匹配元素集合中每个元素紧邻的前一个同胞元素,通过选择器进行筛选是可选的。 根据测试,必须是同胞才行,中间不能有任何无关的元素,比如 <body><div class=”selected”><span>Hello</span></div><br><p class=”selected”>Hello Again</p><p>And Again</p> <script>$(“p”).prev(“.selected”).css(“background”, “yellow”);</script> 这段只能搜索到Hello Again,因为前面多了个br,应该不是同胞了 <body><div class=”selected”><span>Hello</span></div>&l...
get_post_meta
示例 <?php $key_1_value = get_post_meta(76, 'key_1', true); ?> 参数 $post_id (整数)(必需)希望从中得到数据的文章的编号。用$post->ID获取文章编号。 默认值:None $key (字符)(必需)字符,字符中含有希望的meta值的名称。 默认值:None $single (布尔值)(可选)如果默认值设为true,函数返回单个字符形式的结果。如果为false或为设置,则函数返回自定义字段的数组。 默认值:false 返回的值 若$single设为false或空,函数返回一个包含指定关键字的所有值的数组 若$single设为true,函数返回指定关键字的第一个值(不是数组) 无论$single值是什么,如果没有指定关键字,函数将返回空的字符。
php include require区别
根据网上其他人的说法,而且没有什么区别 只有发生“错误”时, include只会提示一个警告,然后继续执行 require会抛出一个致命错误,程序停止
wp_verify_nonce
<?php wp_verify_nonce( $nonce, $action ); ?> $nonce(string) (required) Nonce to verify.Default: None$action(string/int) (optional) Action name. Should give the context to what is taking place and be the same when the nonce was created.Default: -1 Return Values (boolean/integer) Boolean false if the nonce is invalid. Otherwise, returns an integer with the value of: 1 – if the nonce has been generated in the past 12 hours or less. 2 – if the nonce was generated between 12 and 24 hours ...
wordpress中有关即时验证的几个_nonce函数
原文地址:http://www.utubon.com/post/877.html 在wordpress中,为了增加系统的验证安全性,内置了一些简单的验证,这些验证可以有效的防治注册、提交等操作,如果开发者在主题开发中,对数据库进行了操作,一定要使用到这些函数,本文就对这几个函数做一个详细的介绍。 一、wp_create_nonce wp_create_nonce的用法很简单,即一般用在链接中 它将有一个参数,这个参数相当于一个唯一标识ID,通过这个ID,你可以再后文的程序中进行检查。它的返回值即nonce,一个随机字符串。 wp_create_nonce(?$action?); 它的使用例如: <?php?$nonce=?wp_create_nonce??('my-nonce');??> <a?href='myplugin.php?_wpnonce=<?php?echo?$nonce??>'>?... <?php$nonce=$_REQUEST[‘_wpnonce’];if?(!?wp_verify_nonce($nonce,...
解决wordpress函数send_to_editor修改后影响原来自带“添加媒体”功能的问题
要做一个简单的功能,如下图所示,点击上传图片弹出wp的媒体中心 上传图片,结束之后,点击“插入到文章”,这是文本框获取到图片的url, 方法是改写了window.send_to_editor函数,结果发生了冲突,点击自带编辑器的“添加媒体”也还是把图片的url插入到这里 解决方法很简单,就是先记录下原来的函数,当操作完成后再把这个函数还原。 可以不影响自带功能的js代码: jQuery(document).ready(function() {jQuery(‘#uploadBtn’).click(function(){targetfield = jQuery(this).prev(‘#uploadImg’);tb_show(‘’, ‘media-upload.php?type=image&TB_iframe=true’);//打开上传窗口return false;});var original_send_to_editor = window.send_to_editor;window.send_to_ed...
add meta box(添加Meta模块)
<?php add_meta_box( $id, $title, $callback, $post_type, $context,$priority, $callback_args ); ?> $id (字符串)(必需)Meta模块的 HTML“ID”属性 $title (字符串)(必需)Meta模块的标题,对用户可见 $callback (回调)(必需)为Meta模块输出 HTML代码的函数 $post_type (字符串)(必需)显示Meta模块的文章类型,可以是文章(post)、页面(page)、链接(link)、附件(attachment) 或 自定义文章类型(自定义文章类型的别名) $context (字符串)(可选)Meta模块的显示位置(’normal’,’advanced’, 或 ‘side’) 默认值:’advanced’ $priority (字符串)(可选)Meta模块显示的优先级别(’high’, ‘core’, ‘default’or ‘low’) 默认值: ‘default’ $callback_args (数...
wp_editor 函数
<?php wp_editor( $content, $editor_id, $settings = array() ); ?> $content – textarea中的内容 $editor_id – 编辑器的HTML ID,只能包含小写字母 $settings – 设置选项,是一个数组,可以设置的参数包括: wpautop – 是否开启wpautop,默认为true media_buttons – 是否显示上传多媒体的按钮,默认true textarea_name – textarea的name属性,默认与$editor_id相同 textarea_rows – textarea的rows属性,默认是get_option('default_post_edit_rows', 10),这一项在后台设置 tabindex – tabindex数值,tabindex规定用户用键盘的tab键切换表单元素时的顺序。 editor_css – 给编辑器添加css样式,适用于visual和html模式,必须包含<style>标签 teeny –...