我是从jQuery开始的,所以如果质量不好,请原谅我。
我想知道index函数中的含义以及它所指的确切含义。以前我以为它引用的索引号是0、1、2、3等,但是当我通过1,2,3代替索引时,我的代码停止工作。我检查了它的类型,它显示了我的number数据类型。现在让我看看我到底在做什么错以及jQuery中index和Element的概念,因为我在大多数地方都发现了这样的东西-
function(e){
}
Run Code Online (Sandbox Code Playgroud)
我的工作代码-
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$( 'li' ).html(function( index, oldHtml ) {
//alert(typeof($(this).index()));
return oldHtml + '!!!'
});
});
</script>
</head>
<body>
<ul>
<li>This is List item 1</li>
<li>This is List item 2</li>
<li>This is List item 3</li>
<li>This is List item 4</li>
<li>This is List item 5</li>
</ul>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的尝试-
$( 'li' ).html(function( 3, oldHtml ) {....
$( …Run Code Online (Sandbox Code Playgroud) 我是一个jquery首发,所以如果它是一个错误的人原谅我:)
我只是想知道为什么将内容放在不同的位置使这个脚本工作,尽管我最好的想法脚本保留在head文档的部分.请解释一下这个概念.
工作守则
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example 2</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<p>
</p>
<script type="text/javascript">
jQuery("p").html("Check if jQuery Supports Ajax method : "+ jQuery.support.ajax );
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
不工作
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example 2</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
jQuery("p").html("Check if jQuery Supports Ajax method : "+ jQuery.support.ajax );
</script>
</head>
<body>
<p>
</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我很少被我的测验应用程序的数据库设计所困扰.请指导我 -
我的应用UI将会是这样的 -

我的DB表 -
用户 -
user_id
user_name
user_email
user_password
user_registration_date
user_active
Run Code Online (Sandbox Code Playgroud)
问题 -
question_id
question_title
question_category_id
question_level_id
question_author_id
question_status
question_create_date
Run Code Online (Sandbox Code Playgroud)
类别 -
cat_id
cat_name
cat_author
cat_create-date
cat_status
Run Code Online (Sandbox Code Playgroud)
等级 -
level_id
level_name
Run Code Online (Sandbox Code Playgroud)
答案 -
?????????
Run Code Online (Sandbox Code Playgroud)
查询 -
我被困在答案表中data type.意思是我不确定在答案表中设置哪些列与此相关.
我的答案只会在选项格式中表示1,2,3,4选项或选项中没有文字类型答案的真假.只是选择选项.
请指导我,因为我坚持这个.
请在上面提到的表中表示是否有问题,并告诉我是否为单独的表创建了Level OK或者它是坏的(Level只会是 - Beginner,Intermediate,Advance).
来自文档 -
int strlen ( string $string )
Run Code Online (Sandbox Code Playgroud)
它需要字符串作为参数,现在当我这样做时 -
$a = array('tex','ben');
echo strlen($a);
Run Code Online (Sandbox Code Playgroud)
输出 -
5
不过我期待的是,有两种输出 -
如果是数组,php可能会将其转换为字符串,因此数组将变为 -
'texben' 所以它可能输出 - 6
如果第一个不是它会转换它像这样 -
"array('tex','ben')"所以预期的输出应该是 - 18(所有项目的数量)
但每次输出 - 5
我从输出的考虑是5从array字数,但我不知道.如果PHP是这样做的话?(意味着计数5)
以下是使用自定义验证器无法正常工作的架构 -
var mongoose = require('mongoose');
var userSchema = new mongoose.Schema({
email : { type: String, validate: lengthValidator },
});
// Length validator for email
var lengthValidator = function(val){
if(val && val.length >= 6 )
return true;
return false;
};
var User = mongoose.model('User',userSchema);
module.exports = User;
Run Code Online (Sandbox Code Playgroud)
错误 -
Error: Invalid validator. Received (undefined) undefined. See http://mongoosejs.com/docs/api.html#schematype_SchemaType-validate
at SchemaString.SchemaType.validate (/MY_PROJECT_PATH/node_modules/mongoose/lib/schematype.js:416:13)
at SchemaString.SchemaType (/MY_PROJECT_PATH/node_modules/mongoose/lib/schematype.js:38:13)
at new SchemaString (/MY_PROJECT_PATH/node_modules/mongoose/lib/schema/string.js:24:14)
at Function.Schema.interpretAsType (/MY_PROJECT_PATH/node_modules/mongoose/lib/schema.js:367:10)
at Schema.path (/MY_PROJECT_PATH/node_modules/mongoose/lib/schema.js:305:29)
at Schema.add (/MY_PROJECT_PATH/node_modules/mongoose/lib/schema.js:217:12)
at new Schema (/MY_PROJECT_PATH/node_modules/mongoose/lib/schema.js:73:10) …Run Code Online (Sandbox Code Playgroud) 我正在使用Angular UI来使我的菜单可以排序,有时候代码可以工作,有时候它会像重新安排项目那样重复条目或填充空白菜单.
以下是完整的代码 -
<!doctype html>
<html lang="en" ng-app="myapp">
<head>
<title>Angular Sortable Demo</title>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.min.js"></script>
<script>
var myapp = angular.module('myapp', ['ui']);
myapp.controller('controller', function ($scope) {
$scope.list = ["one", "two", "three", "four", "five", "six"];
});
//angular.bootstrap(document, ['myapp']);
</script>
</head>
<body>
<div ng:controller="controller">
<ul ui:sortable ng:model="list">
<li ng:repeat="item in list" class="item">{{item}}</li>
</ul>
<hr />
<div ng:repeat="item in list">{{item}}</div>
</div>
</body>
</html>
<style>
.item, .placeholder {
padding: 2px;
width: 50px;
height: 20px;
border: 1px solid #333;
background: …Run Code Online (Sandbox Code Playgroud) javascript jquery-ui angularjs angular-ui angularjs-ng-repeat
我的滑块不会在第一次导航页面时出现.然而,当我硬刷新页面然后它出现时,如果我用页面内容替换<div ng-view></div>代码,front.html那么滑块也开始工作.让我知道我在角度上做错了什么,因为我认为这是我所缺少的基本功能.
以下是我的布局代码 -
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8" />
<title>WEBSITE</title>
<link rel="stylesheet" href="assets/css/style.css" />
<link rel="stylesheet" href="assets/css/flexslider.css" type="text/css" media="screen" />
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/jquery.flexslider.js"></script>
<script src="assets/js/angular.js"></script>
<script src="assets/js/angular-route.js"></script>
<script src="controllers/mainController.js"></script>
<script>
jQuery(document).ready(function($) {
jQuery(window).load(function() {
jQuery('.flexslider').flexslider({
animation: "slide"
});
});
});
</script>
</head>
<body ng-controller="mainController">
<header ng-include="'includes/header.html'"></header>
<nav ng-include="'includes/navmenu.html'"></nav>
<div ng-view></div>
<footer ng-include="'includes/footer.html'"></footer>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
以下是我的主控制器代码 -
var myApp = angular.module('myApp', ['ngRoute']);
myApp.config(function($routeProvider){
$routeProvider
.when('/', {
templateUrl: 'views/pages/front.html',
controller: …Run Code Online (Sandbox Code Playgroud) 我试图在进行任何更改之前进行表备份,请按照此链接进行查询http://www.w3schools.com/sql/sql_select_into.asp。但是它不起作用并抛出错误#1327 - 未声明的变量:default_table_backup_31_08_2012。让我知道为什么它不起作用?
phpMyAdmin:版本 - 3.4.5。
*笔记:但是我在 phpmyadmin 下找到了一个方法,GOTO->Operations 并执行复制,但我想知道查询中实际的错误是什么,请提供查询方面的解决方案,以便我可以一般使用它:)
我的sql查询-
SELECT *
INTO default_table_backup_31_08_2012
FROM default_table
Run Code Online (Sandbox Code Playgroud) 以下是我在控制器中设置重复选项的代码-
$scope.repeats = [
{name: "No", value: 3},
{name: "Every day", value: 6},
{name: "Every week", value: 9},
{name: "Every month", value: 12},
{name: "Every year", value: 15},
];
Run Code Online (Sandbox Code Playgroud)
以下是用于创建选择选项的HTML模板中的代码-
<select id="repeatval"
ng-model="event.repeat"
ng-options="repeat.value as repeat.name for repeat in repeats"
ng-init="event.repeat = event.repeat || repeats[0].value"
class="btn">
</select>
Run Code Online (Sandbox Code Playgroud)
以下是生成的代码 -
<select class="btn ng-valid ng-dirty" ng-init="event.repeat = event.repeat || repeats[0].value" ng-options="repeat.value as repeat.name for repeat in repeats" ng-model="event.repeat" id="repeatval">
<option value="0">No</option>
<option value="1">Every day</option>
<option value="2">Every week</option>
<option …Run Code Online (Sandbox Code Playgroud) 对不起,如果我在这里丢失了一些愚蠢的东西,但我真的尝试了各种组合来使这个代码工作,但没有运气.
我在学习directive中AngularjS,从Recipes with AngularJS而停留在这个码-
https://github.com/fdietz/recipes-with-angular-js-examples/tree/master/chapter3/recipe4
我相信它应该在Hello World文本之前打印Heading.但它不会来.让我知道我的代码中缺少的内容 - p
代码整体 -
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8" />
<title>Directive Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.min.js"></script>
<script>
var myApp = angular.module("myApp", []);
myApp.directive("myWidget", function(){
return {
restrict: "E",
transclude: true,
template: "<div ng-transclude><h3>Heading</h3></div>"
};
});
</script>
</head>
<body>
<my-widget>
<p>Hello World!!</p>
</my-widget>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) javascript ×5
angularjs ×4
html ×3
jquery ×2
logic ×2
mysql ×2
node.js ×2
sql ×2
angular-ui ×1
arrays ×1
concept ×1
database ×1
datatable ×1
express ×1
jquery-ui ×1
mean-stack ×1
mongodb ×1
mongoose ×1
php ×1
phpmyadmin ×1
selection ×1
strlen ×1
transclusion ×1