我想删除li少于五的索引.所以我使用的是.eq().我知道可以使用if语句完成它但我想在eq()里面使用if语句.
<ul>
<li>0</li>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
$('li').each(function (i) {
$(this).eq(function () {
if (i < 5)
return i;
else
return false;
}).remove();
});
Run Code Online (Sandbox Code Playgroud) 我是php的新手,mvc的新手,yii的新手,以及url-rewriting的新手.所以,对不起,如果我问一些非常基本的东西.
我隐藏了index.php(来自yii论坛中讨论的htaccess方法)
在我的urlmanager中,我有这个,
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>'
),
'showScriptName'=>false,
Run Code Online (Sandbox Code Playgroud)
我在view/site文件夹中有3个文件.
现在,我的主页应该重定向到"旅程"操作(即应该打开'site/journey.php')
所以,我猜,这将是
'/' => 'site/journey'
Run Code Online (Sandbox Code Playgroud)
它也有效.
现在,我希望'旅程/邀请'应该调用'邀请'动作,即应该打开'site/invite.php'
并且,'journey/linkedin'应该调用'linkedin'动作,即'site/linkedin.php'.
但,
'journey/invite' => 'site/invite',
'journey/linkedin' => 'site/linkedin'
Run Code Online (Sandbox Code Playgroud)
不管用.
此外,有人可以帮助我理解这一点,
<controller:\w+>/<id:\d+>
Run Code Online (Sandbox Code Playgroud)
即什么是url中的控制器以及'w +'是什么意思?
对指南的引用也会有所帮助.
在bool.dev的建议之后编辑:
改变了代码,如你所说(我之前也尝试过,删除所有默认规则).现在我的网址管理员就像,
'/' => 'site/journey',
'journey/invite' => 'site/invite',
'journey/linkedin' => 'site/linkedin',
'<controller:\w+>/<id:\d+>'=>'view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
Run Code Online (Sandbox Code Playgroud)
但它会引发错误
"警告:require_once():open_basedir限制有效.文件(/var/xyz.com /../ yii/framework/yii.php)不在允许的路径中:(/ usr/share/php:/usr/share/pear:/ usr/share/php/libzend-framework-php:/ var/* /tmp:/var/xyz.com)第12行/var/xyz.com/journey.php警告: require_once(/var/xyz.com /../ yii/framework/yii.php):无法打开流:第12行/var/xyz.com/journey.php中不允许操作致命错误:require_once():无法打开所需的'/var/xyz.com/../yii/framework/yii.php'(include_path ='.:/ usr/share/php:/ usr/share/php/libzend-framework-php')in第12行的/var/xyz.com/journey.php'
当我做xyz.com/journey/invite 甚至xyz.com/journey
编辑:
这是一个许可问题,@ bool.dev建议将具体规则放在最佳工作上:)
这三个事件之间有什么不同?
哪一个在其他之前/之后加载?
<body>
<script type='text/javascript'>
$(document).ready(function(){
console.log('Document %s',+new Date());
});
$('body').ready(function(){
console.log('Body %s',+new Date());
});
$(window).ready(function(){
console.log('Window %s',+new Date());
});
</script>
<div>hello world</div>
</body>
Run Code Online (Sandbox Code Playgroud)
奇怪的是,它们与我将它们放在代码上的顺序相同.对于当前的例子.document一个先发射,windows另一个发射.
ps我读过window.onload vs <body onload =""/>, window.onload vs document.onload和其他几个.
我有一个jsFiddle来证明我的问题(并允许你们把我拉直).
我只是检查两个输入文本框的值,并在最高价格低于最低价格时提醒用户,但他们正在向后评估!我有,(maxValue < minValue)...但它评估它,就好像操作符"大于".
我错过了什么?!?
<form id="search" action="search.php" method="post">
<label id="lblPriceMin" for="txtPriceMin">Minimum Price</label>
<input type="text" id="txtPriceMin" name="priceMin"></input>
<br />
<br />
<label id="lblPriceMax" for="txtPriceMax">Maximum Price</label>
<input type="text" id="txtPriceMax" name="priceMax"></input>
<br />
<br />
<input type="reset" id="reset" name="reset" value="Clear Form" />
</form>
Run Code Online (Sandbox Code Playgroud)
这是js,
$('#txtPriceMax').focusout(function() {
var minValue = $('input#txtPriceMin').val();
var maxValue = $('input#txtPriceMax').val();
//alert ('minValue: ' + minValue + ', maxValue: ' + maxValue);
if (maxValue < minValue) {
alert ('The maximum value (' + maxValue + …Run Code Online (Sandbox Code Playgroud) 我是Rails的新手并使用此代码进行更新或插入.
user = User.find_by_email(params[:email])
if user.nil?
User.create!(params)
else
user.save(params)
end
// params is a hash with keys as table columns
Run Code Online (Sandbox Code Playgroud)
此代码无效.另外,我想知道Rails是否有一些神奇的东西在一行中做到这一点?
我没有宣布email为主键,但它将是独一无二的.它会帮助我宣布它是主要的吗?
我正在使用display: table并且display: cell具有相同高度的3列布局.
这是我的代码,
HTML:
<div id='wrapper'>
<aside class='column'>Left sidebar</aside>
<div id='main' class='column'>
<textarea rows="2"></textarea><br>Main content <br>
<br><br><br>
</div>
<aside class='column'>Right sidebar</aside>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#wrapper {
display: table;
}
aside {
background-color:#EEE;
margin:0;
padding: 0;
}
.column {
display: table-cell;
}
Run Code Online (Sandbox Code Playgroud)
JS
$('textarea').focus(function () {
$(this).attr('rows',8);
});
Run Code Online (Sandbox Code Playgroud)
这是演示
现在,
当我专注于textarea,textarea增加的高度,因此高度也div#main增加.这增加了padding-top两个aside人的.
我不知道,如果display:table和display:cell它背后的原因,但我不能找出问题.
我是Docker的新手。
据我了解,它创建了可移植的环境,以使用相同的一组软件配置运行应用程序并将其运送到多个平台。这样,它也不会与计算机中的软件冲突。
我已经在开发中使用Docker,并且了解它对于开发以及与其他团队成员共享代码非常有用。每个都可以运行相同的相同软件集。
现在,
我正在考虑在生产中使用docker。在EC2上安装docker,所有内容都将在1个命令中安装/配置。
但是我有几个问题:
$(document).ready(function(){
$(document).bind('keydown',function(e){
key = e.keyCode;
if(key == 37){
left();
}else if(key == 38){
up();
}else if(key == 39){
right();
}else if(key == 40){
down();
}
});
alert("Hi");
});
Run Code Online (Sandbox Code Playgroud)
"嗨"只提醒一下我怎么能$(document).bind在它开始后突破?喜欢break;或者return;可能的东西?
javascript ×3
jquery ×3
html ×2
amazon-ec2 ×1
css ×1
docker ×1
keyboard ×1
padding ×1
url-routing ×1
yii ×1