我有一个计算功能,其中一部分显示了实现目标所需的天数.
而不是仅仅根据数量显示我想要计算天数和月数,天数,月数和年数的天数.我有一个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) 我对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)
希望我一直很清楚 - 我非常感谢任何帮助!
安迪
在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等...
任何想法/帮助将不胜感激!
安迪
我有一个通过wordpress生成的列表项。每个列表项都有一个类,例如cat-item-14。
我只需要操纵此类即可显示数字,以便删除“ cat-item-”并将类保留为“ 14”
任何指针表示赞赏。