小编Kun*_*unj的帖子

单击时切换按钮颜色

JavaScript点击一次,我写了一个将按钮的颜色改为绿色,当我再次点击按钮时,它的颜色应该变回橙色.按钮的默认颜色为橙色.我已经给出了rgb颜色的值.但是,当我点击按钮时,它的颜色从橙色变为绿色,当我再次点击它时,它的颜色保持绿色不会变回橙色.请帮我解决这个问题.

<script>
function colorchange(id)
{

  var background = document.getElementById(id).style.background;

  if(background = "rgb(255,145,0)")
  {
  document.getElementById(id).style.background = "rgb(26,255,0)";
  }
  if(background == "rgb(26,255,0)")
  {
    document.getElementById(id).style.background = "rgb(255,145,0)";
  }

}
</script>
Run Code Online (Sandbox Code Playgroud)

这是输入按钮的HTML代码

<input type="button" name="Ignore Select" value="Ignore Select" id="select" onclick="colorchange('select')" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Delete" value="Ignore Delete" id="select1" onclick="colorchange('select1');" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Insert" value="Ignore Insert" id="select2" onclick="colorchange('select2');" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Update" value="Ignore Update" id="select3" onclick="colorchange('select3');" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Sleep" value="Ignore Sleep" id="select4" onclick="colorchange('select4');" style="background:rgb(255,145,0);"/>
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

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

盒子内的盒子阴影

我想在盒子或 div 内设置盒子阴影,但仅限于右侧和左侧。我想要下面这样的东西。请帮我。

在此输入图像描述

html css

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

<body>未到达页面顶部

困惑,这是html:

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Welcome</title>

    <link rel="stylesheet/less" type="text/css" href="/Styles/CompiledLESS.less" />
    <script src="/Scripts/JS/less-1.5.0.min.js"></script>
</head>
    <body>
        <div id="mainContentDiv">
            <div>
                <h2>Please Log In</h2>
                <p>You must <a href="/Account">Log in</a> to use.</p>
            </div>
        </div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

CSS 这是:

body {
    background-color: #D5E6ED;
    background-image: url("~/Images/Background.jpg");
    background-position: center;
    background-repeat: no-repeat;
    color: #444444;
    font-family: Verdana,Tahoma,Arial,"Helvetica Neue",Helvetica,Sans-Serif;
    font-size: 71%;
    margin: 0;
    padding: 0;
}

#mainContentDiv
{
    margin: 0 auto;
    margin-top:0;
    padding: 0;
    width: 997px;
    background-color:#fff;
}
Run Code Online (Sandbox Code Playgroud)

我看不出有什么不对,但结果是<body>当我用firebug检查时,标签与浏览器窗口的顶部没有齐平.

没有别的CSS,这就是全部.

html css

0
推荐指数
1
解决办法
6503
查看次数

Javascript仅适用于Chrome浏览器,而不适用于Firefox

所以我有一个表,我必须使用表格中的数据来填充模式

使用Javascript

 var tableHeaders = JSON.parse('["name","phone","email","message"]');
        console.log(tableHeaders) ;

$('.openUpdateform').on('click', function() {
  $('#callApi').hide();
  $('#updateData').show();
  tr = $(this).parent().parent().parent().parent();
  console.log(tr.children());
  for (var i = 1; i < tr.children().length - 1; i++) {
    j = i - 1;
    $('#' + tableHeaders[j]).val(tr.children()[i].outerText);
  }

  $('#data_row_id').val($(this).data('row_id'));
  $('#createWF').modal();
})
Run Code Online (Sandbox Code Playgroud)

的jsfiddle

因此上述代码在Chrome上完美运行,但在Mozilla Firefox中没有任何建议.

不工作 从操作下拉意味着,如果您选择的Edit Data选项,它会打开一个弹出窗口和弹出被涂抹在Chrome而不是Firefox浏览器.

谢谢

html javascript firefox jquery google-chrome

0
推荐指数
1
解决办法
266
查看次数

箭头功能难以追踪吗?

我刚才了解到,写下这个:

const setName = name => {
  // set name here
}
Run Code Online (Sandbox Code Playgroud)

与此相反,这是坏事

function setName(name) {
  //set name here
}
Run Code Online (Sandbox Code Playgroud)

原因是第一种方法使调试与该函数相关的问题变得困难,因为它不会出现在堆栈跟踪中.

问题:为什么这不会出现在堆栈跟踪中?

javascript ecmascript-6

0
推荐指数
2
解决办法
636
查看次数

使用 jQuery 添加新输入字段时如何计算总数

$(document).ready(function(){

   $(".price2").keyup(function(){
       total = parseInt($(".price1").val()) + parseInt($(".price2").val());
       $(".total").val(total);
   });
    
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" class="price1" >
<input type="text" class="price2" >
<input type="text" class="total" >
Run Code Online (Sandbox Code Playgroud)

此代码片段执行两个字段的添加并将总数添加到第三个。好的,这看起来不错,但问题是当我使用 jQuery 添加新字段时,总不能工作。即使我使用 jQuery 添加新的输入字段,我应该怎么做才能添加总数

你可以通过下图更好地理解 在此处输入图片说明

我通过以下代码添加新字段

var i = 0;
   $("#addmore").click(function() {
     $("#inputtabletable tr:first").clone().find(".webfield").each(function() {
       $(this).val('').attr({
         'id': function(_, id) {
           return id + i
         },
         'name': function(_, name) {
           return name + i
         },
         'value': ''
       });
     }).end().appendTo("#inputtabletable");
     i++;
   });
Run Code Online (Sandbox Code Playgroud)

使用 jQuery 添加新字段时如何添加总计

html javascript jquery

0
推荐指数
1
解决办法
1212
查看次数

关闭模态后jQuery ajax加载多次

我集成了一个引导模式并包含一个 .js 文件。js文件内容如下。.js 文件用于调用 Ajax。当我按下“加载更多”按钮时,它会触发一次 ajax 函数,这很好。但是,一旦我关闭模式并再次打开它,然后单击“加载更多”按钮,它就会触发 ajax 函数两次。如果我关闭模式并再次打开它并单击“加载更多”按钮,ajax 函数将触发三次。我的问题是:如果单击“加载更多”按钮,如何仅加载 ajax 函数一次?场景应该是:

  1. 我点击了加载更多并调用了ajax。

  2. 我关闭了模式并再次打开它。我单击了“加载更多”按钮并启动了 ajax(仅一次)。如果我再次单击“加载更多”按钮,它将再次调用 ajax 函数。

等等。

$(document).ready(function(){
   $(document).on('click','#btn-more',function(){
       var id = $(this).data('id');
       var token_csrf = $("#csrfToken").val();
       var base_path_loadata = $("input[name='base_path_loadata']").val(); 
       $("#btn-more").html("Loading....");
       $.ajax({
           url : base_path_loadata,
           method : "POST",
           data : {id:id, _token:token_csrf},
           dataType : "text",
           success : function (data)
           {
              if(data != '') 
              {
                  $('#remove-row').remove();
                  $('#load-data').append(data);
              }
              else
              {
                  $('#btn-more').html("No Data");
              }
           }
       });
   });  
});
Run Code Online (Sandbox Code Playgroud)
<div id="remove-row">
                <button id="btn-more" data-id="{{$lastId}}" class="nounderline btn-block mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" …
Run Code Online (Sandbox Code Playgroud)

ajax jquery

0
推荐指数
1
解决办法
1372
查看次数

标签 统计

html ×5

javascript ×4

jquery ×4

css ×2

ajax ×1

ecmascript-6 ×1

firefox ×1

google-chrome ×1