小编Ash*_*ani的帖子

parseInt不起作用

在我当前的源代码文本框值是1.当我尝试alert(isNaN(obj.text())它返回false预期但在我写alert(a);它后parseInt 返回NaN

minus.click(function () {
     var a = 1; if (!isNaN(obj.text())) a = parseInt(obj.text()); 
     if (a > 1) a -= 1; obj.text(a);
});
Run Code Online (Sandbox Code Playgroud)

问题是什么?

编辑:这是完整的代码:

<input type="text" class="basket-txt" value="1" />


jQuery.fn.basket = function (options) {
    var defaults = {
    }
    options = jQuery.extend(defaults, options);
    this.each(function () {
        var $this = $(this);
        $this.height(32).css({ 'line-height': '32px', 'font-weight': 'bold', 'width':'40px', 'text-align':'center', });
        var tbl = $('<table border="0" style="border-spacing:0px;float:left;">').appendTo($this.parent());
        var tr1 = $('<tr>').appendTo(tbl);
        var plus = $('<div …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

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

多次使用相同的选择与创建临时表

我有类似的代码

select count(*) from(
select t1.col1, t1.col2, t1,col3, t2.col2 from table1 t1
left join table2 t2 on t1.col1=t2.col1) x

select * from(
select t1.col1, t1.col2, t1,col3, t2.col2 from table1 t1
left join table2 t2 on t1.col1=t2.col1) x
where x.col1 > 10
Run Code Online (Sandbox Code Playgroud)

我选择并加入具有相同列的相同表两次。如果我这样做:

declare @table table(col1 int,col2 int,col3 varchar,col4 int)
insert into @table(col1,col2,col3,col4) select * from (
select t1.col1, t1.col2, t1,col3, t2.col2 from table1 t1
left join table2 t2 on t1.col1=t2.col1
) x
select count(*) from @table
select * from @table …
Run Code Online (Sandbox Code Playgroud)

sql sql-server

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

SQL Server:按给定因子多次选择一行

我想从表中选择,但问题是,我有一个因子列,指示必须选择此行的次数(这是一个仅用于演示的示例表):

ID        Factor         Count
-------------------------------
1            1             235        
2            2             345        
3            2             214        
4            3             95        
5            1             135        
6            1             750  
Run Code Online (Sandbox Code Playgroud)

查询:

select top 6 
   [id], [count] 
from 
   table
order by 
    id                  --somewhere in here I must take factor into consideration
Run Code Online (Sandbox Code Playgroud)

结果必须是:

ID            Count
---------------------
 1            235                    
 2            345                    
 2            345                    
 3            214                    
 3            214                    
 4            135        
Run Code Online (Sandbox Code Playgroud)

sql sql-server

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

对于具有字节计数器的循环在开始时挂起

这是一个非常简单的for循环:

for (byte i = 0; i <= 255; i++)
{
    //do something
}
Run Code Online (Sandbox Code Playgroud)

在我变为0后循环挂起,直到视觉工作室终于停止运行,但为什么?

如果我将计数器类型更改为int,它可以完美地工作.

c# loops for-loop visual-studio

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

使用CultureInfo时,DateTime.Parse返回错误的值

这是我的代码:

DateTime Now = DateTime.Parse(DateTime.Now.ToString(), new System.Globalization.CultureInfo("fa-ir"));
Run Code Online (Sandbox Code Playgroud)

Geogorian日期是:2016年6月16日

波斯日期是:13/03/1395

而现在的价值是:07/09/2025

时间是对的.可能是什么问题?

c# datetime parsing

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

Isracard 的 RegEx(以色列卡)

我需要 Isracard(以色列信用卡)的正则表达式。

将非常感谢您的帮助,或者可能提供一些如何制作的信息。

Isracard 8-9 位数字的格式。

前任。卡片图片 - http://images.delcampe.com/img_large/auction/000/157/341/572_001.jpg

javascript c# regex

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

我想要一个高效的排序算法来对数组进行排序

for (int i = 1; i < data.Count; i++) 
{
    int j = i;
    while (j > 0)
    {
        if (numarray[j - 1] > numarray[j])
        {   
            int temp = numarray[j - 1];
            numarray[j - 1] = numarray[j];
            numarray[j] = temp;
            j--;

        }

        else
            break;
    }
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮我确定上面代码的排序算法是什么吗?我知道冒泡排序效率不高。如果我要改用插入排序算法,我该如何改进上面的代码。谢谢!

c# arrays sorting bubble-sort insertion-sort

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

T型默认值

我有几个扩展方法一样ParseInt,ParseLong,ParseByte.现在我正在尝试为所有这些方法制作一个扩展方法.问题是,要使Default参数可选,我必须给它一个值T Default = 0,但它会生成错误:

"int"类型的值不能用作默认参数,因为没有标准转换来键入"T"

如果我像那样使用它T Default = (T)0我会得到另一个错误:

无法将类型'int'转换为'T'

这是我的扩展方法:

public static T Parse<T>(this string x, T Default = 0)
        {
            Type type = typeof(T);
            if(type == typeof(int))
            { if(!string.IsNullOrEmpty(x) int.TryParse(x , out Defualt); return Default;  }
        }
Run Code Online (Sandbox Code Playgroud)

c# extension-methods types

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

使用:不排除css中的类

我正在尝试将css应用于特定类中的所有跨度但排除其中一些,但以下代码不起作用:

.basket-items li span:not(.name,.count){border:solid 1px #ddd; border-radius:50%;}
Run Code Online (Sandbox Code Playgroud)

我一直都:not喜欢这样:not(:empty).它不接受CSS课程吗?

这是html:

<ul class="basket-items">
    <li>
          <span class="ion-android-close"></span>
          <span class="name"></span>
          <span class="ion-plus"></span>
          <span class="count"></span>
          <span class="ion-minus"></span>
    </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

PS:请注意,在这里排除类意味着产生与类似问题不同的结果:我可以有多个:not()选择器吗?

css css-selectors css3

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

需要一个随机数发生器

我需要生成一个介于-0.5和0.5之间的随机数。

我已经尝试了用户Anthony Pegram的堆栈溢出解决方案。我已经对其进行了一些修改(我需要在console.write行中调用和使用该方法)

public static float nextfloat()
{
     Random random = new Random();
     double val = random.NextDouble();
     val -= 0.5;
     return float.MaxValue * (float)val;
}
Run Code Online (Sandbox Code Playgroud)

通过尝试这个,我得到的数字超出-0.5和0.5,我得到类似

1.7 1.005等

c# random floating-point double

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