我使用jQuery方法来获取某些类型的html对象:
var content = $('#cke_ckeditor iframe').contents().find('.cke_show_borders').clone();
Run Code Online (Sandbox Code Playgroud)
然后我想将其转换为string类型:
console.log(content[0].toString());
Run Code Online (Sandbox Code Playgroud)
但结果是:
[object HTMLBodyElement]
Run Code Online (Sandbox Code Playgroud)
我怎样才能把它变成真正的字符串?
顺便说一下,我可以将转换后的html字符串转换为html对象吗?
if (function f() {}) {
console.log(f) // Throw an error: f is not defined
}
Run Code Online (Sandbox Code Playgroud)
为什么日志会导致错误,f上面的表达式中还没有定义?
你期望这相当于:
function f () {}
if (true) {
console.log(f); // Throw an error: f is not defined
}
Run Code Online (Sandbox Code Playgroud) 这是我的html标记:
<input type="checkbox" checked="false">
Run Code Online (Sandbox Code Playgroud)
我已将其设置checked为false,但仍会检查结果
为什么会这样?如果我删除checked属性,它将取消选中.
其实我想input[type=checkbox]在动态中插入一个html标记,用参数来确定是否选中
我有一个简单的html5视频标签:
<video autobuffer="true" id="video" controls="true">
<source src="some_url"></scource>
</video>
Run Code Online (Sandbox Code Playgroud)
我没有在视频标签或css中定义明显的宽度和高度,视频包装器会根据源视频大小进行调整,问题是,如何获得视频当前宽度和高度?我试过jquery
$('video').css('width');
Run Code Online (Sandbox Code Playgroud)
但它返回原始大小:300px
我在页面中看到的是800px!
我怎么解决这个问题?
在某些情况下,我认为translateZ并且scale具有相同的效果,就像放大或缩小一样.
我认为它们之间有一些计算连接,如果我知道它们的一个值,就像translateZ(-1000px)和父perspective值一样,我可以计算出scale具有相同效果的值translateZ吗?
当我使用Chrome devtools的配置文件工具记录javascript CPU运行时间,并切换到火焰图时,我看到很多颜色块,一些块的颜色看起来相似,有些是不同的.
每种颜色代表什么?有什么区别?
假设我有几个javascript对象
{"type":"gotopage","target":"undefined"}
{"type":"press","target":"a"}
{"type":"rotate","target":"long"}
Run Code Online (Sandbox Code Playgroud)
如何将此对象添加到另一个对象中
config={}
Run Code Online (Sandbox Code Playgroud)
我知道如果每个插入的对象都有一个id我可以添加为:
config["id"]={}
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,如何添加没有id的对象?
我想在使用模块时定义一个控制器:
angular.module('todoList', [], function () {
}).controller('myCtrl', function ($scope) {
return function ($scope) {
$scope.todos = [
{
text: "Hello"
}, {
text: "World"
}
]
}
})
Run Code Online (Sandbox Code Playgroud)
然后我想使用模块和ccontroller:
<div ng-controller="myCtrl" ng-app="todoList">
<li ng-repeat="todo in todos">
<span>{{todo.text}}</span>
</li>>
</div>
Run Code Online (Sandbox Code Playgroud)
但它没有渲染,我的代码有什么问题?
例如,我打开一个网页,向下滚动到某个位置,
然后我刷新Chrome浏览器,浏览器可以再次滚动前一个位置
如何使用javascript或css让浏览器忘记滚动?
我试过了$(window).scrollTop(0),但它不起作用
假设我有一个功能:
function test(){}
test.prototype.method01=function(){
//do something
}
test.prototype.method02=function(){
//how can I call the method01?
//this.method01()...?
//but the chrome through an error:
//Uncaught TypeError: Object #<HTMLImageElement> has no method 'method01'
}
Run Code Online (Sandbox Code Playgroud)
编辑:实际上方法01是这样的:
test.prototype.method02=function(){
$('.cpy').resizable({
}).draggable({
start:function(e,ui){
this.method01();
}
});
}
Run Code Online (Sandbox Code Playgroud)