小编mpl*_*jan的帖子

如何将对象的空属性拼接成数组?

所以我有一个对象数组,我想在它为空时切片对象的属性.

例如:

var quotes = [
{
    quote: "Bolshevism is not a policy; it is a disease. It is not a creed; it is a pestilence.",
    source: "Winston Churchill",
    citation: "",
    year: "29 May 1919",
    place: ""
},
{
    quote: "Learn while you live",
    source: "",
    citation: "X",
    year: "1950",
    place: ""
}];
Run Code Online (Sandbox Code Playgroud)

我有一个对象列表,对象名称随机为空.

我想打印到页面只有非空的属性.

所以我试图遍历对象以找到indexOf()空属性并拼接它:

function findEmptyProp(quotes) {
   for (prop in quotes) {
     if(quotes[i].children === '') {
        return indexOf(quotes[i]);
        quotes.splice(i, 1);
}}}
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助

javascript arrays object splice

3
推荐指数
1
解决办法
1327
查看次数

jQuery元素没有删除

我想删除元素,id=decoratives / Interior但它不起作用.

如果由于特殊字符而无法正常工作,那么我该如何更改/空白?

$(".remove").on("click", function(e) {
  e.preventDefault();
  var category = $(this).data("cat");
  $('#' + category.replace(/\s/g, '')).remove();
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="decoratives/Interior">
  <a class="fancybox-gallery" href="http://wallpapercraze.com/images/wallpapers/nowallpaper-585747.jpeg">
    <img class="animate scale animated" src="http://wallpapercraze.com/images/wallpapers/nowallpaper-585747.jpeg" alt="Image1" style="height:75px">
    <div class="image-hover">
      <i class="icon-zoom-in-2"></i>
    </div>
  </a>
  <br>
  <a class="remove" data-cat="decoratives / Interior">Remove Image</a> 

</div>
Run Code Online (Sandbox Code Playgroud)

html jquery

3
推荐指数
1
解决办法
35
查看次数

如何使用字符串中的javascript获取锚标记的href值

如何使用纯javascript,在没有Jquery的情况下,在下面的字符串内容中获取最后一个锚标记的href值.

var contents = '<div id="content"><a href="http://www.okhype.com/wp-content/uploads/2016/12/ruffcoin-made-in-aba.jpg"><img title="Ruffcoin-Made-In-Aba.jpg" class="alignnone size-full" alt="image" src="http://www.okhype.com/wp-content/uploads/2016/12/ruffcoin-made-in-aba.jpg" /></a>????Indigenous heavyweight, <a href="http://www.okhype.com/tag/ruffcoin">Ruffcoin</a> recently dropped a new album titled “Made In Aba“. I’ve been giving it a few spins, and I must say, the album is quite solid.??[matrix]??Two of my early faves are “Aba Made” and “Higher Higher which feature <a href="http://www.okhype.com/tag/sparkle">Sparkle</a>)”. You should check ’em out, then download on iTunes <a href="https://itunes.apple.com/us/album/made-in-aba/id1180901826?ign-mpt=uo%3D4"><strong>hereq</strong></a>.??Cop below.??[audio mp3="http://www.okhype.com/wp-content/uploads/2016/12/Ruffcoin_-_Aba_Made_Okhype.com_.mp3"][/audio]<strong><a href="http://www.okhype.com/wp-content/uploads/2016/12/Ruffcoin_-_Aba_Made_Okhype.com_.mp3">DOWNLOAD Ruffcoin - Aba Made</a></strong>??[audio mp3="http://www.okhype.com/wp-content/uploads/2016/12/Ruffcoin_ft_Sparkle_-_Higher_Higher_Okhype.com_.mp3"][/audio]<strong><a href="http://www.okhype.com/wp-content/uploads/2016/12/Ruffcoin_ft_Sparkle_-_Higher_Higher_Okhype.com_.mp3">DOWNLOAD Ruffcoin ft Sparkle - Higher …
Run Code Online (Sandbox Code Playgroud)

html javascript

3
推荐指数
1
解决办法
617
查看次数

单击按钮时不触发表单验证

我有一个由两个按钮组成的表单。它们都没有类型中的“提交”声明。

我的问题是,在两次单击按钮期间都会触发表单验证,因为我希望验证仅在单击一个特定按钮时发生。这能实现吗?

下面是我的代码。

<form class="form-horizontal" ng-controller="checkoutCtrl" name="ordersubmitform">
  <div class="panel panel-default" ng-init="init()">
    <div class="panel-body">
      <div class="row">
        <div class="col-md-6">
          <fieldset>
            <legend class="text-semibold">PERSONAL INFO</legend>
            <div class="form-group">
              <label class="col-lg-3 control-label">Name</label>
              <div class="col-lg-9">
                <input type="text" ng-model="customer.name" name="username" class="form-control" required/>
              </div>
            </div>
            <div class="form-group">
              <label class="col-lg-3 control-label">E-Mail</label>
              <div class="col-lg-9">
                <input type="email" ng-model="customer.email" name="email" class="form-control" required />
              </div>
            </div>
            <div class="form-group">
              <label class="col-lg-3 control-label">Mobile Number</label>
              <div class="col-lg-9">
                <input ng-model="customer.contact" type="text" name="mobile" class="form-control" pattern=".{9,}" required title="9 characters minimum" />
              </div>
            </div>
            <legend class="text-semibold">ADDRESS</legend>
            <div class="form-group">
              <label class="col-lg-3 control-label">Organisation …
Run Code Online (Sandbox Code Playgroud)

html javascript validation jquery angularjs

3
推荐指数
1
解决办法
1878
查看次数

下载使用MVC5选择的多个文件

我正在 MVC5 中开发一个如下所示的视图:

在此处输入图片说明

我需要选择表的一个或多个记录,并能够在数据库中下载以前保存的文件。我一直在寻找解决方案并进行了多次测试,但我找不到解决方案。我试图从 javascript 将选定的代码发送到控制器并从中下载文档,但我无法做到。下载可能是在您可以的情况下,获取所有文件并生成一个 zip,或者自动将所有文件下载到浏览器的默认文件夹。我将不胜感激任何可以帮助我的人......您好!

这是我的 ajax 调用:

  $.ajax({
            type: "POST",
            url: "/GestionGarantias/Garantias/Download",
            data: { pCodigo: mCodigo },//Here I would send the list of //codes, but now to test, I only call the controller regardless of the value, //because the values in the list set them in the handy controller to test.
            xhrFields: {
                responseType: 'blob'
            },
            success: function (data) { //Here should I bring a zip with all files supposedly?
                var a = document.createElement('a');
                var url = …
Run Code Online (Sandbox Code Playgroud)

javascript c# asp.net-mvc-5

3
推荐指数
2
解决办法
4585
查看次数

React-router-dom 重定向不起作用 - 显示错误

我的反应应用程序react-router-dom无法工作。它显示错误

类型错误:path_to_regexp__WEBPACK_IMPORTED_MODULE_8___default.a.compile 不是函数

查看图像

未捕获的类型错误:path_to_regexp__WEBPACK_IMPORTED_MODULE_8___default.a.compile 不是函数在反应应用程序中显示错误


我不知道为什么会显示 react-router-dom 的错误问题

检查我的代码

该代码显示错误


import React from 'react'
import DefaultLayout from './Component/Layout/DefaultLayout';
import DefaultLogin from './Component/Login/DefaultLogin';
import DefaultSignup from './Component/Sign-up/DefaultSignup';



// react-router-dom

import { BrowserRouter as Router, Route, Switch, Redirect } from "react-router-dom";


// bootstrap css
import 'bootstrap/dist/css/bootstrap.min.css';

// css for global 
import './App.scss';


export default function App() {
    return (
        <>
            <Router>   

                <Switch> 
                        <Route path="/admin" exact component={DefaultLayout} />
                        <Route path="/admin/signup"  component={DefaultSignup} />
                        <Route path="/admin/login"  component={DefaultLogin} />
                        <Redirect from="/" to="/admin" />
                </Switch> 


            </Router>            
        </>
    ) …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-router react-router-v4 react-router-dom

3
推荐指数
1
解决办法
4125
查看次数

使用streams().reduce 从ArrayList&lt;Integer&gt; 构建一个字符串?

JavaScript 中,我们可以使用 reducer 构建其他类型的字符串(例如 num to string):

const string = [1,2,3,4,5].reduce((acc,e) => acc += e, "") //"12345"
Run Code Online (Sandbox Code Playgroud)

Java 中,从其他类型构建字符串时,这种模式并不容易:

ArrayList<Integer> arrayListOfIntegers = (ArrayList<Integer>) Arrays.asList(1,2,3,4);
String string = arrayListOfIntegers.stream().reduce("", (String acc, Integer e) -> acc += e); // acc += e throws error
Run Code Online (Sandbox Code Playgroud)

错误是:

“错误的返回类型:字符串不能转换为整数”

这种模式在 Java 中是不可能的吗?

javascript java reduce binary-operators java-stream

3
推荐指数
1
解决办法
198
查看次数

如何在加载页面后禁用提交按钮10秒

我的问题可能很简单,但我只有一周的编程时间,而且我无法理解我能找到的相对答案.所以...需要你的绝地帮助.如何在加载页面后禁用提交按钮10秒?谢谢!

javascript php button

2
推荐指数
1
解决办法
2496
查看次数

试图获取被点击对象的属性

我正在尝试从单击其链接时获取对象的标头值.

例如,当我点击链接时,我试图获得值"2014_BUDGET".

我尝试了各种各样的变化.

  • 尝试得到.prop()而不是.attr.
  • 试过搜索 .closest('td')
  • 试图得到父母attr.

一切都以警报结束'undefined'.

这是我的代码

<td headers="2014_BUDGET" class="MYCLASS"><a 
href="javascript: alert(  $(this).closest('td').attr('headers')  );">1</a></td>

<td headers="2014_BUDGET" class="MYCLASS"><a 
href="javascript: alert(  $(this).attr('headers')  );">1</a></td>
Run Code Online (Sandbox Code Playgroud)

javascript jquery

2
推荐指数
1
解决办法
42
查看次数

如何在Ajax发布中传递多个json对象以在conTroller中获得相同的内容

我在这里和谷歌都经历过所有可能的问题.没有找到任何有用的或者我不知道如何相应地更改代码.JQuery中的新功能.请参阅下面的代码.

在表单中,主条目和详细信息条目存在.这里Employee部分是Master,而Member部分是详细信息,包含多行.我需要点击一个按钮传递所有记录.

var Employee = {
        "Title": "",
        "FirstName": "",
        "MiddleName": "",
        "LastName": "",
        "Gender": ""
    }
    Employee.Title = $('#ddltitle').val();
    Employee.FirstName = $('#txtfname').val();
    Employee.MiddleName = $('#txtmname').val();
    Employee.LastName = $('#txtlname').val();
    Employee.Gender = $('#ddlgender').val();

    var Member = {  
        "Membername": "",
        "Relation": "",
        "Gender": "",
        "DOB": "",
        "Age": ""
    }

    Member.Membername = $('#txtmem1').val() + "," + $('#txtmem2').val() + "," + $('#txtmem3').val() + "," + $('#txtmem4').val() + "," + $('#txtmem5').val();
    Member.Relation = $('#ddlrel1').val() + "," + $('#ddlrel2').val() + "," + $('#ddlrel3').val() + "," + …
Run Code Online (Sandbox Code Playgroud)

jquery asp.net-mvc-4

2
推荐指数
1
解决办法
9523
查看次数