或者说,有可能吗?
就像当用户上传一些动画 gif 时(实际上不是上传,只是从本地计算机选择它们到浏览器),然后使用一些 JavaScript 来执行以下操作:
尝试使用 jQuery 显示选定的图像并在单击图像时删除图像。
单击时删除图像工作正常,实际上问题是它不会从表单中删除。
$(document).ready(function() {
/*multiple image preview first input*/
$("#files").on("change", handleFileSelect);
selDiv = $("#selectedFiles");
$("#myForm").on("submit", handleForm);
$("body").on("click", ".selFile", removeFile);
/*end image preview */
});
var selDiv = "";
// var selDivM="";
var storedFiles = [];
function handleFileSelect(e) {
var files = e.target.files;
var filesArr = Array.prototype.slice.call(files);
var device = $(e.target).data("device");
filesArr.forEach(function(f) {
if (!f.type.match("image.*")) {
return;
}
storedFiles.push(f);
var reader = new FileReader();
reader.onload = function(e) {
var html = "<div><img src=\"" + e.target.result + "\" data-file='" + …Run Code Online (Sandbox Code Playgroud)我有这个新闻解析器.我需要在这里添加图片.它们的超链接将从XML解析.如何升级我的xmlParser?我需要div内的图像,通过CSS为图像提供正确的位置.并为此图像分配给div的CSS类.
我试过补充一下
<div class="articleimg">' + <img src='"+$(this).find("image").text()+"'/> + '</div>
Run Code Online (Sandbox Code Playgroud)
但似乎我的语法不正确.添加此类代码后,如何追加整行?
从头开始:
function xmlParser(xml) {
$('#load').fadeOut();
$(xml).find("item").each(function () {
$(".main").append('<div class="article"><div class="title">' + $(this).find("title").text() + '</div><div class="full">' + $(this).find("description").html() + '</div><div class="date">?????????: ' + $(this).find("pubDate").text() + '</div></div>');
$(".article").fadeIn(500);
});}
Run Code Online (Sandbox Code Playgroud)
来自身体:
<div class="main">
<div id="loader" class="loader"><img src="../images/theme/loader.gif" alt="loader" id="load" width="64" height="64" style="vertical-align:middle;"/></div>
</div>
Run Code Online (Sandbox Code Playgroud)
来自xml文件:
<?xml version="1.0" encoding="utf-8" ?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"
xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<item>
<title>Title</title>
<description>Description</description>
<image>http://website.com/images/news/news.png</image>
<pubDate>2018/03/10 00:00:00 GMT+3</pubDate>
</item>
</channel>
</rss>
Run Code Online (Sandbox Code Playgroud) 我已经在父级中创建了具有相同类的3 div,并在子元素上添加了活动类,并在单击第二个子元素时再次添加了活动类,但是这次我要删除第一个元素的活动状态。如何有效删除它?
这是我的代码
<div class="tab-div">
<div class="tab">default</div>
<div class="tab" >hover</div>
<div class="tab">active</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的javascript
var elements = document.querySelectorAll('.tab');
for (var i = 0; i < elements.length; i++) {
elements[i].classList.remove('active');
elements[i].onclick = function (event) {
console.log("ONCLICK");
if (event.target.innerHTML === this.innerHTML) {
this.classList.add("active");
}
}
}
Run Code Online (Sandbox Code Playgroud) 我在 Bootstrap 上有折叠内容,我尝试.pannel-heading在情况a[aria-expanded="true]属实时更改背景。
是否可以<a>在这里再添加一个标签并且不会影响它们折叠?
这是 HTML
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">
<h4>title </h4>
<button class="button">Sign up</button>
<a data-toggle="collapse" data-parent="#accordion" href="#" class="" aria-expanded="true">sample text</a>
</div>
</div>
<div id="collapse-SortTechnician-1" class="panel-collapse collapse in" aria-expanded="true" style="">
<div class="panel-body">
<div class="block1 block constraint-container no-bg ">
<div class="constrain content-block clearfix">
<div class="richtext ">
<p>sample text</p>
</div>
</div>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我在 jQuery 中尝试过的,但还没有工作。
$(function(){
if ($('.panel-heading .panel-title > a').attr('aria-expanded') === "false") {
alert("false");
$('.panel-title').css('background','#fff');
} else if($('.panel-heading …Run Code Online (Sandbox Code Playgroud) 我有两个控制器,其中一个我声明了一个$ scope变量,我希望在第二个控制器中可见.
第一控制器
app.controller('Ctrl1', function ($scope) {
$scope.variable1 = "One";
});
Run Code Online (Sandbox Code Playgroud)
第二控制器
app.controller('Ctrl2', function ($scope, share) {
console.log("shared variable " + share.getVariable());
});
Run Code Online (Sandbox Code Playgroud)
我研究了最好的Angular方法,我发现这是使用服务.所以我添加了一项服务Ctrl1
服务
.service('share', function ($scope) {
return {
getVariable: function () {
return $scope.variable1;
}
};
});
Run Code Online (Sandbox Code Playgroud)
此代码返回此错误:
Unknown provider: $scopeProvider <- $scope <- share
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:可能在控制器之间共享$ scope变量吗?不是最好的角度解决方案或者我错过了什么?
对不起我的琐碎问题,但我是一名Angular初学者.
提前致谢
问候
我正在寻找一种明确的方法来确保JavaScript垃圾收集器很快就能完成它的工作.
那么设置变量undefined是一种保证吗?
var foo = "something";
// do stuff with foo
foo = undefined;
// awake the Garbage Collector interest to him
Run Code Online (Sandbox Code Playgroud) 我在这里做了一个简单的演示:https : //jsfiddle.net/bwmgazfx/1/
这行 CSS 适用于 Chrome 和 IE11。
*, html { cursor: none !important; }
Run Code Online (Sandbox Code Playgroud)
在 Chrome 和 IE11 中,光标是隐藏的,但在 Firefox(版本 60)中,当您按住鼠标按钮时,光标有时会隐藏,否则会保持可见。我知道光标:无;在 Firefox 中工作,但我似乎无法追踪为什么它没有被隐藏的问题。
我的问题是,为什么 Firefox 61 中没有隐藏光标?
我正在尝试即时创建一个数据列表并将其附加到现有的输入元素。但是什么也没有发生(没有显示下拉箭头)jQuery 也是可以接受的。
var optionList = ["Seattle", "Las Vegas", "New York", "Salt lake City"];
function fillDataList() {
var container = document.getElementById('my-text-box'),
i = 0,
len = optionList.length,
dl = document.createElement('datalist');
dl.id = 'dlCities';
for (; i < len; i += 1) {
var option = document.createElement('option');
option.value = optionList[i];
dl.appendChild(option);
}
container.appendChild(dl);
}
Run Code Online (Sandbox Code Playgroud)
小提琴:https : //jsfiddle.net/tomsx/704cxako/
(取自本网站的示例:http : //blogs.microsoft.co.il/gilf/2012/07/30/quick-tip-autocomplete-using-html5-datalist-element/)
HTML:
<p><b id="msg" name="msg" style="visibility:hidden; color:#3399ff;">msg</b></p>
Run Code Online (Sandbox Code Playgroud)
JS:
$('#url').on('change keyup paste',function(){
$('#msg')style.visibility('visible');});
Run Code Online (Sandbox Code Playgroud)
请问我该怎么做?