草庐IT

values-w

全部标签

javascript - Select2.js v4.0 : how set the default selected value with a local array data source?

通过使用select2.jsv4插件,当我使用本地数组数据作为源时,如何设置默认选择值?以这段代码为例vardata_names=[{id:0,text:"Henri",},{id:1,text:"John",},{id:2,text:"Victor",},{id:3,text:"Marie",}];$('select').select2({data:data_names,});如何设置id3为默认选中值? 最佳答案 $('.select').select2({data:data_names,}).select2("val",3);

javascript - lodash/js : Filtering values within an object based on regular expressions and getting the highest by comparison

对于下面的json[{"index":"xyz",...},{"index":"abc1234",...},{"index":"xyz",...},{"index":"abc5678",...}...我想分别过滤掉abc值和xyz值。我尝试了以下方法来获取值varx=_.filter(jsonData,function(o){return/abc/i.test(o.index);});它可以提供过滤后的输出。现在我想获得最高的abc值,如果有值abc123,abc444,abc999那么代码应该返回abc999。我可以使用lodash再次循环,但这是否可以在一次调用中完成-在同一个过滤

javascript - 与 document.forms[0].elements[i].value; 等效的 jQuery 是什么?

什么是jquery等效于:document.forms[0].elements[i].value;?我不知道如何在jQuery中遍历表单及其元素,但想知道该怎么做。 最佳答案 通常的翻译是:input选择器:$("form:first:input").each(function(){alert($(this).val());//alertsthevalue});:first是因为您的示例提取了第一个,如果只有一个或您想要所有输入元素,只需使用:first离开。:inputselector适用于,,...您通常关心的所有元素都在这里。

javascript - 谷歌可视化堆叠条形图 : colors and labels for each value

我正在使用GoogleVisulaizationAPI来呈现一个图表,该图表显示具有多个值的单行,如下所示:使用以下代码:vardata=google.visualization.arrayToDataTable([['','0%','25%','50%','75%','100%',{role:'annotation'}],['Mood',3,7,20,25,45,'']]);varoptions={isStacked:true,hAxis:{minValue:0}}varchart=newgoogle.visualization.BarChart(document.getElemen

Javascript getElementsByName.value 不起作用

这个问题在这里已经有了答案:WhatdoquerySelectorAllandgetElementsBy*methodsreturn?(12个答案)关闭1年前。我正在尝试制作一个简单的javascript程序,但它无法正常工作。请帮忙。在Eclipse中,我创建了一个动态Web项目,在DD中,我的欢迎文件是index.jsp。下面给出了我的index.jsp代码Duncan'SfunctionnameSubmit(){alert(document.getElementsByName("username").value);}functionCakeNumber(){alert(docum

Javascript : onchange event does not fire when value is changed in onkeyup event

这个问题在这里已经有了答案:Javascript:"onchange"eventdoesnotworkwith"value"changein"textinput"object(1个回答)关闭9年前。我有这个简单的代码:我不知道为什么当我按下键时文本框的值发生了变化,但onchange事件没有触发。我怎样才能触发onchange事件?

javascript - jQuery 日期时间选择器 XDsoft : How do I get value from inline calendar?

我使用XDSoft的jQueryDatetimepicker插件:http://xdsoft.net/jqplugins/datetimepicker/我有内联显示的日历。这是我的代码:HTML:JS:jQuery('#start_date').datetimepicker({format:'d.m.YH:i',inline:true});我的问题:当我在前端选择一个日期时,输入字段没有将所选日期作为值。我需要进行哪些更改或需要添加哪些内容? 最佳答案 从Onchange事件中获取值试试这个onChangeDateTime:func

javascript - Uncaught ReferenceError : show value is not defined(Only for mobile device)

您好,我已经实现了代码,其中在添加到购物车时会添加商品,还会打开一个显示购物车商品的弹出窗口。在桌面上它运行良好,但在移动设备上它不工作。对于移动设备,它是shoingingerrorasUncaughtReferenceError:showvalueisnotdefined下面是我的代码functionshowvalue(value,product){$('#').text(product);$('#').text(value);$('.cart_popup').show();setTimeout(function(){$('.cart_popup').fadeOut('slow')

javascript - 为什么 "[value=' ' ]"throw an exception in IE7 and ":not(:not([value ='' ]))"does not?

我正在尝试通过jQuery从选择框中选择选项标签(值为“”的选项)。我使用以下选择器:$("[value='']");这适用于大多数浏览器,但在IE7中它会抛出异常。如果我将其更改为以下(恕我直言)选择器,则它可以正常工作:$(":not(:not([value='']))");我宁愿不使用后者,但想不出更好的等价物。编辑:jQuery版本:1.3.1.异常:MicrosoftJScript运行时错误:抛出异常但未捕获在if(S==null){throw"Syntaxerror,unrecognizedexpression:"+ab}在哪里ab="value='']"测试设置:为确保我

javascript - {...object, property : value} work with spread syntax? 如何

在查看ES6文档时,我注意到建议使用扩展语法而不是更冗长的Object.assign()方法。但是,我对这是如何实现的有点困惑。在这种情况下object是否被分解为key:value对,之后添加或覆盖逗号右侧的属性,最后被重新组装? 最佳答案 Isobjectinthiscasebeingbrokendowntokey:valuepairs,afterwhichthepropertyontherightofthecommaiseitheraddedoroverwritten,andfinallybeingreassembled?原始