jquery函数在jsfiddle上工作但不在我的站点cakephp上

时间:2022-10-20 16:01:43

I have got stuck in a dump issue but am not able to work it out , I have a range selection of age through two select input buttons. I took the code from the mark up and it works on the fiddle but not on the page.

我陷入了转储问题,但我无法解决问题,我通过两个选择输入按钮选择了年龄范围。我从标记中取出代码,它在小提琴上工作,但不在页面上。

I have tried putting the script on the view file,layout header and at the end of view.

我已经尝试将脚本放在视图文件,布局标题和视图的末尾。

But it never worked.

但它从来没有奏效。

1 个解决方案

#1


1  

There must be some JS error. Track down any error you may be getting using Firebug in Firefox or Chrome Inspector in Google Chrome. Make sure you have included jQuery.js in your cakephp page. Also please note that it's not supported in all the browsers, so you can use Polyfill if there is any browser specific issue.

必须有一些JS错误。跟踪使用Firefox中的Firebug或Google Chrome中的Chrome Inspector可能遇到的任何错误。确保在cakephp页面中包含jQuery.js。另请注意,并非所有浏览器都支持它,因此如果存在任何特定于浏览器的问题,您可以使用Polyfill。

Updates:

更新:

Lets try another approach, instead of getting the value of first input on clicking the second one, What if we try to set a value for second input on changing the first one.

让我们尝试另一种方法,而不是在点击第二个时获取第一个输入的值,如果我们尝试在更改第一个输入时设置第二个输入的值,该怎么办?

$("input#range1").bind('change',function(){
   $("input#range2").val(this.value);
});

Demo: http://jsfiddle.net/VBrEj/12/

演示:http://jsfiddle.net/VBrEj/12/

#1


1  

There must be some JS error. Track down any error you may be getting using Firebug in Firefox or Chrome Inspector in Google Chrome. Make sure you have included jQuery.js in your cakephp page. Also please note that it's not supported in all the browsers, so you can use Polyfill if there is any browser specific issue.

必须有一些JS错误。跟踪使用Firefox中的Firebug或Google Chrome中的Chrome Inspector可能遇到的任何错误。确保在cakephp页面中包含jQuery.js。另请注意,并非所有浏览器都支持它,因此如果存在任何特定于浏览器的问题,您可以使用Polyfill。

Updates:

更新:

Lets try another approach, instead of getting the value of first input on clicking the second one, What if we try to set a value for second input on changing the first one.

让我们尝试另一种方法,而不是在点击第二个时获取第一个输入的值,如果我们尝试在更改第一个输入时设置第二个输入的值,该怎么办?

$("input#range1").bind('change',function(){
   $("input#range2").val(this.value);
});

Demo: http://jsfiddle.net/VBrEj/12/

演示:http://jsfiddle.net/VBrEj/12/