我正在开展一个项目,我需要听听这个scroll活动..我想知道什么是更好的方法..
function scroll() {
if ($(window).scrollTop() > 200) {
top.fadeIn();
} else {
top.fadeOut();
}
if (menuVisible) {
quickHideMenu();
}
}
Run Code Online (Sandbox Code Playgroud)
function scroll() {
didScroll = true;
}
setInterval(function() {
if ( didScroll ) {
didScroll = false;
if ($(window).scrollTop() > 200) {
top.fadeIn();
} else {
top.fadeOut();
}
if (menuVisible) {
quickHideMenu();
}
}
}, 250);
Run Code Online (Sandbox Code Playgroud)
谢谢 :)
我已经编写(并复制)了几行Javascript,它很有用.但我试图找出一种更好的方法(跨浏览器和更好的性能)来做到这一点.我isInteger从朋友那里复制了这个函数但是我不明白为什么我们在以下条件中检查字符串值:
if (((c < "0") || (c > "9"))) return false;
Run Code Online (Sandbox Code Playgroud)
上面的条件工作正常,但是当我更改它以检查数字值时,功能会中断.输入字段开始接受字母字符.这是我改变时的样子:
if ((( c < 0 ) || ( c > 9 ) return false;
Run Code Online (Sandbox Code Playgroud)
我试图评论部分,以便您可以了解正在发生的事情.此代码中是否还有安全漏洞?我读到1innerHTML1方法可以打开一些安全漏洞,因此我们需要用它执行"清理"操作.因此我选择使用jQuery的.html方法(我是JavaScript的新手)
有问题的页面:http://thehotdeal.net/clients/wehtmlit/index.php?order /
$(document).ready(function() {
var total = 0;
function calcTotal() {
/* fetching some values from PHP variables and then performing calculations.
essentially this is multiplying number of pages by price per page
*/
/* <![CDATA[ */
var total_price_main_pages = ($("#pages").attr("value")) * (<?php echo $main_price; ?>), …Run Code Online (Sandbox Code Playgroud) 我试图direction动态设置,但有些东西不起作用.我没有收到错误.
function moveSelection(keyPressed) {
var group = canvas.getActiveGroup(),
obj = canvas.getActiveObject();
if(!group && !obj) {return;}
var direction = '',
sign = '',
operators = {
'+': function(a, b) { return a + b },
'-': function(a, b) { return a - b },
};
switch(keyPressed) {
case 37:
direction = 'left';
sign = '-';
break;
case 38:
direction = 'top';
sign = '-';
break;
case 39:
direction = 'right';
sign = '+';
break;
case 40:
direction = 'bottom'; …Run Code Online (Sandbox Code Playgroud) 我正在尝试注册自定义验证规则但它似乎不起作用.我需要填写2个字段中的任何一个.一个是URL(链接)字段,另一个是文件输入(file_upload).这是我的自定义验证:
Validator::register('file_check', function($attribute, $value, $parameters) {
if (!trim($value) == "" || array_get(Input::file($parameters[0]), 'tmp_name')) {
return true;
}
return false;
});
$messages = array(
'file_check' => 'Please upload a file or provide a link to files.',
);
$rules = array(
'link' => 'url|file_check:file_upload',
'file_upload' => 'mimes:jpg,jpeg,gif,png,psd,ai,bmp,xls,xlsx,doc,docx,zip,rar,7z,txt,pdf'
);
$validation = Validator::make(Input::all(), $rules, $messages);
if ($validation - > fails()) {
return Redirect::to('page') - > with_errors($validation - > errors) - > with_input();
}
Run Code Online (Sandbox Code Playgroud)
需要帮忙 :)
EDITED
此外,我只是注意到验证规则应该接受"PSD"文件,但是当我尝试上传PSD文件时,它会重定向并显示错误"无效的文件类型".
public function action_detail($orderId)
{
$customerWithOrderDetails = Customer::with(array('order' => function($query)
{ global $orderId;
$query->where('id', '=', $orderId);
}, 'order.orderdetail', 'order.attachment'))->find(Auth::user()->id);
return var_dump($customerWithOrderDetails);
}
Run Code Online (Sandbox Code Playgroud)
我收到"变量未定义"错误.为什么?
我正在尝试在聚焦时让文本框放大
相关的HTML代码是
<input class="tbox" name="q" type="text" />
Run Code Online (Sandbox Code Playgroud)
由于tbox是页面中每个文本框的标记,我必须使用该名称.
我试过这个javascript
window.onload = init();
function init()
{
var arr = new Array();
arr = document.getElementsByName("q");
var querybox = arr[0];
querybox.addEventListener('onfocus', wasclicked, false);
querybox.addEventListener('onblur', lostfocus, false);
}
function wasclicked(form)
{
form.q.style['width'] = '500px';
}
function lostfocus(form)
{
form.q.style['width'] = '276px';
}
Run Code Online (Sandbox Code Playgroud)
调试控制台告诉我,我不能在未定义的上使用addEventListener.
我不熟悉javascript,所以我尝试[0] .value也无济于事.
users transactions tasks
+----+--------+ +----+---------------+ +----+--------+
| id | name | | id | name | | id | name |
+----+--------+ +----+---------------+ +----+--------+
| 1 | User 1 | | 1 | Transaction 1 | | 1 | Task 1 |
| 2 | User 2 | | 2 | Transaction 2 | | 2 | Task 2 |
+----+--------+ +----+---------------+ +----+--------+
templates transaction_user task_transaction
+----+---------------+ +---------+----------------+ +---------+----------------+
| id | name | | user_id | transaction_id | | …Run Code Online (Sandbox Code Playgroud) javascript ×3
laravel ×3
php ×3
jquery ×2
database ×1
fabricjs ×1
html ×1
mysql ×1
optimization ×1
performance ×1
validation ×1
variables ×1