\r\n\r\n用setInterval制作的代码如下:\r\n\r\njQuery代码:\r\n
function changeColor(){\r\n\tjQuery('#MessageBtn').toggleClass('MessageBtn');\r\n}\r\njQuery(function (jQuery) {\r\n\tsetInterval('changeColor()',500);\r\n});\r\n\r\nhtml代码:\r\n
<span id=\"MessageBtn\">马上试试</span>\r\n\r\ncss代码:\r\n
#MessageBtn{display:block;width:129px;height:35px;position:absolute;top:356px;right:68px;border:2px solid #fff;text-index:-999em;}\r\n.MessageBtn{border:2px solid #fff;}","post_title":"用setInterval制作不间断闪动提示","post_excerpt":"用setInterval制作html演示页的不间断按钮,由于整体项目用到的都是jquery框架,于是就没有用原生的js,不用jQuery请绕行。","post_name":"jquery_setinterval_tips","post_modified_gmt":"2012-05-22T17:37:10.000Z"},{"ID":67,"post_content":"最近,在做wordpress的模板,全部都是自己来,对wordpress不太熟悉,在写搜索模板的时候被卡住了,我是这样写的:\r\n
<form method=\"get\" id=\"searchForm\" action=\"<?php bloginfo('url'); ?>\">\r\n<input type=\"text\" value=\"\" name=\"search\" id=\"searchTxt\" class=\"inputTxt\" x-webkit-speech placeholder=\"请输入搜索关键词\" />\r\n<input type=\"submit\" value=\"搜索\" id=\"searchBtn\" class=\"inputBtn\" />\r\n</form>\r\n一直修改search.php模板,奇怪怎么没效果?wordpress的搜索模板是哪个?参考了很多的网站,原来技巧在input的name上,我写的name=“search”,而wordpress的默认的搜索需要用name=“s”,把“search”改成“s”,问题立马解决,正确的代码如下:\r\n
<form method=\"get\" id=\"searchForm\" action=\"<?php bloginfo('url'); ?>\">\r\n<input type=\"text\" value=\"\" name=\"s\" id=\"searchTxt\" class=\"inputTxt\" x-webkit-speech placeholder=\"请输入搜索关键词\" />\r\n<input type=\"submit\" value=\"搜索\" id=\"searchBtn\" class=\"inputBtn\" />\r\n</form>\r\n","post_title":"wordpress的搜索模板无效?","post_excerpt":"","post_name":"wordpress_search_page","post_modified_gmt":"2013-08-16T05:52:02.000Z"},{"ID":55,"post_content":"最近在做一个套wordpress模板,刚好用到“上一篇、下一篇”的功能,看了找了挺多资料,没有找到满意的,我就奇怪,怎么wordpress功能那么强大,应该有“上一篇、下一篇”的功能,结果皇天不负苦心人人呀,看了官方的资料,终于弄到想要的代码:\r\n
<section id=\"postNextPrev\">\r\n\t<?php previous_post('<p>上一篇: %</p>','','yes'); ?>\r\n\t<?php next_post('<p>下一篇:%</p>','','yes'); ?>\r\n</section>\r\n我自己的页面本来就有检查查询数据库的函数,结果只是多了一个查询记录,结果还挺满意,各位童鞋如果有自己写模板的可以看看自己的模板产生了几条查询。\r\n\r\n参考地址:http://codex.wordpress.org/Function_Reference/next_post","post_title":"为wordpress添加“上一篇、下一篇”","post_excerpt":"找了很多资料,都能实现“上一篇、下一篇”的功能,但看了数据库查询记录,哇哦!一下多了好多了条,不甘心,就上官方找到满意的代码。","post_name":"previous_post-next_post","post_modified_gmt":"2013-08-16T05:47:08.000Z"},{"ID":38,"post_content":"读了上一篇“jquery实现简单的Placeholder跨浏览器兼容问题”,你是不是觉得可以还在进一步呢!\r\n\r\n之前的代码是这样的:\r\n
var searchValue = \"请输入搜索关键词\";\r\nif ( !( 'placeholder' in document.createElement('input') ) ){\r\n\tjQuery(\"#search\").removeAttr(\"placeholder\").val(searchValue).bind(\"focus\",function(){\r\n\t\tif (this.value==searchValue){this.value=\"\";};\r\n\t}).bind(\"blur\",function(){\r\n\t\tif (this.value==\"\"){this.value=searchValue;};\r\n\t});\r\n}else{\r\n\tjQuery(\"#search\").bind(\"focus\",function(){\r\n\t\tif ( jQuery(this).attr('placeholder') == searchValue ){ jQuery(this).attr('placeholder','') };\r\n\t}).bind(\"blur\",function(){\r\n\t\tif ( jQuery(this).attr('placeholder','') ){ jQuery(this).attr('placeholder',searchValue) };\r\n\t});\r\n}\r\n下面我就来说说这个的方式的改进,我们还可以做的更好。\r\n
(function(){\r\n\tvar searchText = jQuery('#searchText');\r\n\tvar searchValue = searchText.attr('placeholder');\r\n\tif ( !( 'placeholder' in document.createElement('input') ) ){\r\n\t\tsearchText.removeAttr('placeholder').val(searchValue).bind('focus',function(){\r\n\t\t\tif ( this.value==searchValue) {this.value=''; };\r\n\t\t}).bind('blur',function(){\r\n\t\t\tif ( this.value=='' ){ this.value=searchValue; };\r\n\t\t});\r\n\t}else{\r\n\t\tsearchText.bind('focus',function(){\r\n\t\t\tif ( jQuery(this).attr('placeholder') == searchValue ){ jQuery(this).attr('placeholder','') };\r\n\t\t}).bind('blur',function(){\r\n\t\t\tif ( jQuery(this).attr('placeholder','') ){ jQuery(this).attr('placeholder',searchValue) };\r\n\t\t});\r\n\t}\r\n})();\r\n我用\"var searchText = jQuery('#searchText');\"来改进\"var searchValue = '请输入搜索关键词';\"这样我们就可以直接在html中输出placeholder的值也不用去顾虑value怎么办!\r\n\r\n到这里你是否觉得OK了?那如果一个页面上要是有多个输入框,难道要重复写上这么一段,NO!我们还可以做的更好,jQuery为我们提供了很好的插件机制,我们可以利用jQuery的插件把上面那段代码封装成一个插件。\r\n
(function($){\r\n\t/*******************************\r\n * @name Placeholder跨浏览器兼容插件 v1.0\r\n\t * @author norion\r\n\t * @author blog http://zkeyword.com/\r\n\t * @2012.04.15\r\n\t * @可自由转载及使用,但请注明版权归属\r\n\t *******************************/\r\n\t$.fn.placeholder = function(){\r\n\t\tvar searchText = this;\r\n\t\tvar searchValue = searchText.attr('placeholder');\r\n\t\tif ( !( 'placeholder' in document.createElement('input') ) ){\r\n\t\t\tsearchText.removeAttr('placeholder').val(searchValue).bind('focus',function(){\r\n\t\t\t\tif ( this.value==searchValue) {this.value=''; };\r\n\t\t\t}).bind('blur',function(){\r\n\t\t\t\tif ( this.value=='' ){ this.value=searchValue; };\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tsearchText.bind('focus',function(){\r\n\t\t\t\tif ( jQuery(this).attr('placeholder') == searchValue ){ jQuery(this).attr('placeholder','') };\r\n\t\t\t}).bind('blur',function(){\r\n\t\t\t\tif ( jQuery(this).attr('placeholder','') ){ jQuery(this).attr('placeholder',searchValue) };\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n})(jQuery);\r\njQuery(function (jQuery) {\r\n\tjQuery('#searchText').placeholder();\r\n});\r\n\r\n\r\n这样我们就可以重复利用这段代码了,当然我们还可以做的更好,如果有高手路过,还请拍砖。","post_title":"“jQuery实现Placeholder跨浏览器兼容问题”的改进","post_excerpt":"改进“jquery实现简单的Placeholder跨浏览器兼容问题”将其封装成jQuery插件,如果有高手路过,还请锦上添花。","post_name":"jquery_placeholder_2","post_modified_gmt":"2012-05-18T01:02:08.000Z"},{"ID":35,"post_content":"近来忙在做公司的事情,下班没啥时间研究新东西,曾经在一个音乐电台听过那主持人才在调侃:“如果有人问青春是什么,青春就是拿我们最宝贵的东西去换我们最想要的东西”,这还真被太说中了。\r\n\r\n题外话说多了,下面来说这Placeholder跨浏览器兼容的问题,当然这个是根据我的理解方式来写的,不如意处还请拍砖:\r\n
var searchValue = \"请输入搜索关键词\";\r\nif ( !( 'placeholder' in document.createElement('input') ) ){\r\n\tjQuery(\"#search\").removeAttr(\"placeholder\").val(searchValue).bind(\"focus\",function(){\r\n\t\tif (this.value==searchValue){this.value=\"\";};\r\n\t}).bind(\"blur\",function(){\r\n\t\tif (this.value==\"\"){this.value=searchValue;};\r\n\t});\r\n}else{\r\n\tjQuery(\"#search\").bind(\"focus\",function(){\r\n\t\tif ( jQuery(this).attr('placeholder') == searchValue ){ jQuery(this).attr('placeholder','') };\r\n\t}).bind(\"blur\",function(){\r\n\t\tif ( jQuery(this).attr('placeholder','') ){ jQuery(this).attr('placeholder',searchValue) };\r\n\t});\r\n}\r\n其中关键是一句是用!( 'placeholder' in document.createElement('input')来判断当前的浏览器是否支持placeholder,不支持就调用最传统的设置value的方法。","post_title":"jquery实现简单的Placeholder跨浏览器兼容问题","post_excerpt":"html5中Placeholder跨浏览器兼容的问题,写了个脚本来优化一下,当然这个是根据我的理解方式来写的,不如意处还请拍砖。","post_name":"jquery_placeholder","post_modified_gmt":"2012-04-26T19:23:12.000Z"},{"ID":30,"post_content":"有时候你用的i++和++i的时候是不是有点迷糊呢?下面我来列个例子简单看出二者的区别:\r\n
//i++和++i的区别\r\nvar h = 0,i = 0;\r\nj = h++;\r\nk = ++i;\r\nalert(h);\r\nalert(i);\r\nalert(j);\r\nalert(k);\r\n\r\n","post_title":"简单的例子看出i++和++i的区别","post_excerpt":"有时候你用的i++和++i的时候是不是有点迷糊呢?下面我来列个例子简单看出二者的区别","post_name":"ii","post_modified_gmt":"2012-04-22T22:01:09.000Z"},{"ID":21,"post_content":"不知道哦哪里看来的面试题,题目大概是这样:\r\n
var n = 0;\r\nvar show = function(){\r\n c = n+1;\r\n alert(c);\r\n}\r\n(function (){\r\n d = n+2;\r\n alert(d);\r\n})()\r\n请你解答这段代码的最后输出的结果是什么,并解释原因。\r\n\r\n如果你运行这段代码你会发现,输出的是1而不是2,是因为show的匿名函数后面没有用分号来结束,导致下面的出错了,加上分号之后就正常了。\r\n\r\n平时如果养成主动加上分号的习惯,就可以减少很多莫名的bug。","post_title":"不知道哪里看来的javascript面试题","post_excerpt":"基础性的javascript面试题挺不错的,如果你是个javascript老手,温故而知新一下,如果你是新手不忘拿笔记一下哦!","post_name":"javascript_interview_questions","post_modified_gmt":"2012-05-22T17:37:39.000Z"},{"ID":2,"post_content":"