Tag: 函数

jQuery里面的函数调用另一个函数= undefined?

我想在身体之前调用另一个function,但是如何? 系统显示错误undefined function myx 我只能在身体后添加代码。 jQuery(function($){ function myx() { alert(“omg”); }; }); jQuery(document).ready(function($){ $(“mytest”).click(function(){ myx(); }); }); Check

javascript中的Jquery需要两次点击

我用jquery写了一个simpe内联编辑。 插件工作得很好,但是我在javascript函数中调用脚本时遇到问题,需要2次点击才能激活插件。 有谁知道解决这个问题的方法..我只想点击一下! 提前致谢。 Let’s update function update(id) { $(“#edit” + id).kb_edit(); }

Fancybox – 将函数应用于多个元素

下面的源代码由Cristiano G. Carvalho在回答问题时发布: 使用其他用户制作的其他链接调用fancybox gallery 。 Manual Call Fancybox $(document).ready(function(){ $(“.manualfancybox”).click(function() { var photos = new Array(); $(“.details_gallery_min a”).each(function(){ href = $(this).attr(“href”); title = $(this).attr(“title”); photos.push({‘href’: href, ‘title’: title}) }); jQuery.fancybox(photos , { ‘transitionIn’ : ‘elastic’, ‘easingIn’ : ‘easeOutBack’, ‘transitionOut’ : ‘elastic’, ‘easingOut’ : ‘easeInBack’, ‘opacity’ : false, ‘titleShow’ : true, ‘titlePosition’ : ‘over’, ‘type’ […]

for循环中的函数(js / jquery)

我在for循环中调用一个函数,但该函数似乎无法正常工作 $(document).ready(function(){ function fn_get_natural_dim(){ var width = this.width; var height = this.height; var ratiow = width/600; var ratioh = height/300; if(ratiow>=ratioh) { height = height/ratiow; $(slide_image).css(“width”,”600px”); $(slide_image).css(“height”,height); var margin = (300-height)/2; $(slide_image).css(“margin-top”,margin); } else { width = width/ratioh; $(slide_image).css(“width”,width); $(slide_image).css(“height”,”300px”); var margin = (600-width)/2; $(slide_image).css(“margin-left”,margin); } } var max_count = $(“.slider”).children().length; for(var count=1;count<=max_count;count++) { var […]

javascript子函数传递返回父函数返回

我想将一个“孩子”(我不知道正确的术语)函数的返回值传递给父函数中的返回…这样做的正确方法是什么? check_data()未返回true或false function check_data(type,field){ var chkvalue = $(field).val(); $.post(“mods/ajax.fieldchk.php”, { chkvalue: chkvalue, type: type }, function(result){ if(result==0){ $(field).css({‘background-color’: ‘#faa’, ‘border’: ‘1px solid #f00’}); return false; }else if(result==1){ $(field).css({‘background-color’: ‘#afa’, ‘border’: ‘1px solid #0f0’}); return true; } }; } 日Thnx

在jquery ready块中定义的函数和一个外部函数之间的区别是什么

我将一个函数注册到一个带有onclick属性的按钮,并在$()块中定义了这个函数(我知道这是一个不好的做法,它只是一个例子),当我点击按钮时,出现错误:Uncaught ReferenceError:你好没有定义。 这是我的代码: $(function(){ function hello(){ alert(‘hello’); } }); 如果我把函数代码放在$()块之外,它就可以了。 我知道在解析DOM时执行$(),当我单击按钮时,DOM必须已经被解析,那么为什么它会报告错误? 谢谢。

仍有问题通过function回归价值

我遇到以下function的严重问题: function requestUploadedSearch() { var cookie = JSON.parse(readCookie(“user_search_cookie”)); $.ajax({ dataType: “script”, async: false, data: { context: “search-get”, code: removeNull(cookie, cookie !== null, “code”) }, success: function(data) { var keywords = search_return[“keywords”]; return keywords; // here is the damn problem. } }); } 除了未定义的值之外,几乎没有任何东西出现的接缝,并且调试器中没有显示错误。 我真的差点把我的笔记本电脑扔在墙上。 如果有人可以帮我这样做,请回答! 提前致谢。

JQuery使用title和src属性

我正在查看一个脚本,只需勾选一个复选框就会获得输入的src属性,然后通过所有其他复选框和单选按钮。 .each并删除任何输入的checked属性,标题属性为’RQlevel’ + this.src 。 希望足够清楚。 这是我的尝试,但这是不正确的。 function levels() { if ($(this).is(‘:not(:checked)’).each(function()) { if($(‘:input’).attr(‘title’, ‘RQlevel’ + this.src) { $(‘:input’).removeAttr(‘checked’); }); }); } http://jsfiddle.net/V8FeW/上的工作示例

为什么不能达到这个function?

为什么没有达到fadeOut的function? 每次运行该函数时,它都会刷新页面而不是使用AJAX。 我知道这可能是一个微不足道的问题,但我被困住了。 任何帮助都可以让我睡个好觉。 谢谢 function deleterow(id){ if (confirm(‘Are you sure want to delete?’)) { $.post(‘delete.php’, {id: +id, ajax: ‘true’ }, function(){ $(“#row_”+id).fadeOut(“slow”); }); } } 这是php的html输出:

压缩我的jQuery

如何压缩我的jQuery有用? 我想在我hover另一个时添加一个显示元素的函数。 下面的function正是我想要的,但我希望它更具动感。 也许有数据属性? var item_first = $(‘.item_first’); var item_second = $(‘.item_second’); var item_third = $(‘.item_third’); var item_fourth = $(‘.item_fourth’); var image_first = $(‘.image_first’); var image_second = $(‘.image_second’); var image_third = $(‘.image_third’); var image_fourth = $(‘.image_fourth’); $(document).ready(function () { item_first.hover(function () { image_first.addClass(‘active’); }, function () { image_first.removeClass(‘active’); }); item_second.hover(function () { image_second.addClass(‘active’); }, function […]