-1

I have two strings one brings me a time ie:

var gettime= $("#select-choice-2 :selected").text();

it gives me time in 24 hr format like this

17:45

but i want my time to be in a format like

17:45:00.000

for which i made a string

var ext=':00.000';

I want these two strings to concatenate in such a way to give me proper result.

I see now whats the problem is my "gettime" is not a proper string, i tried it to show in alertbox but nothing happens, so please tell me how to convert gettime into a string.

I got it "gettime" is a local variable and ext is using in some other function thats why "gettime" was not appearing in alertbox, stupid ehh :p

4

4 回答 4

2

只需使用连接运算符:

alert( gettime + ext );
于 2012-07-30T07:15:55.853 回答
0

你只是想把字符串加在一起吗?在这种情况下:

var bothstrings = gettime + ext;
于 2012-07-30T07:16:55.547 回答
0

**
范围问题,我现在明白了。gettime 是某个函数中的局部变量,而 ext 保存在不同的函数中,这就是为什么函数 gettime 没有出现在 alertbox 中的原因**

于 2012-07-30T07:52:41.410 回答
0

如果您直接在字符串之间分配一个来连接它们,某些浏览器可能会导致结果字符串出现+换行符。标准的做法是——

gettime.concat(ext)
于 2012-07-30T07:25:45.737 回答