你们是否知道CDN可以让你加载JavaScript库,就像谷歌和jQuery以及其他一些人一样.
我正在寻找一个托管CodeMirror库的.
我想知道如果我在H1标题中添加一个列表是否会有任何问题:
<h1>
<ul>
<li><a href="...">some link</a></li>
<li><a href="...">another link</a></li>
<li>current page</li>
</ul>
</h1>
Run Code Online (Sandbox Code Playgroud)
该列表是"面包屑"类型导航.
或者将其插入列表中更好?
<ul>
<li><a href="...">some link</a></li>
<li><a href="...">another link</a></li>
<li><h1>current page</h1></li>
</ul>
Run Code Online (Sandbox Code Playgroud) 如何按字母顺序对数组进行排序:
$allowed = array(
'pre' => array(),
'code' => array(),
'a' => array(
'href' => array(),
'title' => array()
),
'strong' => array(),
'em' => array(),
);
// sort($allowed); ?
Run Code Online (Sandbox Code Playgroud)
?
我正在尝试计算pre元素的行数,我正在使用它:
var numlines = $('#mypreelement').text().match(/\n\r?/g).length + 1;
Run Code Online (Sandbox Code Playgroud)
它有效,但在某些情况下我得到一个错误
错误:$('#mypreelement').text().match(/ \n\r?/ g)为null
这只发生在某些页面上,但这些页面与其工作的页面没有任何不同,当然除了内容......
为什么?
你们可以发布电子邮件链接垃圾邮件保护方法(在php或javascript中)吗?
基本上我想在网页上放一个"mailto"链接,比如
<a href="mailto:pony@fuu.com">E-mail me</a>
但我不希望垃圾邮件机器人拿起它然后用阴茎扩大电子邮件给我发垃圾邮件:)
到目前为止,我在这里找到了一个javascript混淆器:http://www.jottings.com/obfuscator/不确定它的效果如何..
有没有办法获取页面的内容,例如http://google.com,并将其插入当前文档,但就像iframe的方式,我的意思是...有样式,脚本和页面的所有内容?
并使样式和脚本不影响当前文档:)
有谁知道是否有一个?
我想使用变量名称调用函数.
我在这里发布了一个小提琴我想要做的事:
<div id="some">
...
</div>
Run Code Online (Sandbox Code Playgroud)
JS:
(function($){
$.fn.MyPlugin = function(){
return this.each(function(){
var somefunction = function(arg1, arg2){ alert(arg1); },
someotherfunction = function(arg1, arg2){ alert(arg2); },
reallyimportantfunction = function(arg1, arg2){
var foo = $(this).attr('id') + 'function';
// here I want to call the function with the foo value as name, and pass it arg1 and arg2
$()[foo](arg1, arg2); // <- doesn't work
};
reallyimportantfunction();
});
};
})(jQuery);
jQuery(function($){
$('#some').MyPlugin ();
});
Run Code Online (Sandbox Code Playgroud) 我注意到很多脚本都有这些类型的注释:
/**
* Retrieve list of themes with theme data in theme directory.
*
* The theme is broken, if it doesn't have a parent theme and is missing either
* style.css and, or index.php. If the theme has a parent theme then it is
* broken, if it is missing style.css; index.php is optional. The broken theme
* list is saved in the {@link $wp_broken_themes} global, which is displayed on
* the theme list in the administration panels.
* …Run Code Online (Sandbox Code Playgroud) 我注意到如果我在一个与外部函数同名的类方法中声明一个函数,我会收到一个错误:
function a(){
...
}
class foo{
public function init(){
function a(){ // <- error
...
}
...
}
}
Run Code Online (Sandbox Code Playgroud)
但这会起作用:
function a(){
...
}
class foo{
public static function a(){
...
}
}
Run Code Online (Sandbox Code Playgroud)
我可以使用require_once或类似的东西包含一组作为此类的静态方法的函数吗?
require_once('file.php');之后class foo{不起作用......
如果在PHP5中通过引用传递对象,那么$foo下面的原因不会改变?
$foo = array(1, 2, 3);
$foo = (object)$foo;
$x = $foo; // $x = &$foo makes $foo (5)!
$x = (object)array(5);
print_r($foo); // still 1,2,3
Run Code Online (Sandbox Code Playgroud)
所以:
通过引用传递与assign不同.
那么为什么$foo以下(100, 2, 3)呢?
$foo = array('xxx' => 1, 'yyy' => 2, 'zzz' => 3);
$foo = (object)$foo;
$x = $foo;
$x->xxx = 100;
print_r($foo);
Run Code Online (Sandbox Code Playgroud)