小编tbw*_*wcf的帖子

使用jQuery将数字(天)转换为天,月和年

我有一个计算功能,其中一部分显示了实现目标所需的天数.

而不是仅仅根据数量显示我想要计算天数和月数,天数,月数和年数的天数.我有一个if语句用于拆分,但似乎无法计算数学从例如132天到x天x个月...任何建议?

// GOAL
var timeToGoal = Math.round(goal / costPerDay);         

// if more than a year
if ( timeToGoal >= 365 ) {
    alert('days + months + years');

    // if more than a month but less than a year
} else if ( timeToGoal >= 30 && timeToGoal <=365 ) {
    alert('Days + months');
} else {
    alert('days');
    $('#savings-goal span').text(timeToGoal+' days');
}
Run Code Online (Sandbox Code Playgroud)

javascript math

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

jquery转到表单提交的URL,并将字段值添加到url字符串

我对jquery相当新,我认为这很简单,但我很挣扎,谷歌似乎没有帮助....

我所拥有的是基本形式......

<form>
First Name: < input type="text" name="firstName" id="firstName" />
Surname: < input type="text" name="surname" id="surname" />
<input type="submit" id="submit" value="submit"/>
</form>
Run Code Online (Sandbox Code Playgroud)

现在,当点击提交时,我想转到一个网址但是然后将froms值添加到url字符串(但不使用表单方法= get)基本上我希望这发生

点击提交转到 http://myurl.com/index.html?params=firstNamevalue*surnamevalue

我一直在用jquery进行攻击,但是我最喜欢的就是这样......

< script src="http://www.google.com/jsapi" type="text/javascript">< /script>
< script type="text/javascript">
    google.load("jquery", "1.3.1");
</script>

< script type="text/javascript">

var = firstName $("#firstName").val();
var = surname $("#surname").val();


$('#submit').click(function(){
  window.location = ???;
}); 
< /script>
Run Code Online (Sandbox Code Playgroud)

希望我一直很清楚 - 我非常感谢任何帮助!

安迪

string url jquery params

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

jQuery将各种id加载到页面的各个部分

在WordPress我已经成立了一个随机后拉页,使用jQuery我期待此刻的代码是低于本(随机)页当前(主页)上的各个部分的部分拉:

$('#wrongQuote').load('random/index.php #wrongSaying' + '?noCache=' + Math.floor(Math.random()*10001));
$('#sayingBy').load('random/index.php #author' + '?noCache=' + Math.floor(Math.random()*10001));
$('#actualQuote').load('random/index.php #actualSaying' + '?noCache=' + Math.floor(Math.random()*10001));

麻烦的是,这是拉动随机#wrongSaying,#author和#actualSaying ...我需要的是得到随机的,但配套#wrongSaying/#author/#actualSaying

所以我想我需要的是在该网页"随机/ index.php文件#wrongSaying"然后拿DIV#x和插入的div#A,DIV#楼为DIV#E等...

任何想法/帮助将不胜感激!

安迪

jquery load

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

jQuery删除部分类名

我有一个通过wordpress生成的列表项。每个列表项都有一个类,例如cat-item-14。

我只需要操纵此类即可显示数字,以便删除“ cat-item-”并将类保留为“ 14”

任何指针表示赞赏。

jquery replace class

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

标签 统计

jquery ×3

class ×1

javascript ×1

load ×1

math ×1

params ×1

replace ×1

string ×1

url ×1