好吧,所以我研究这个已经太久了 请帮助我理解为什么它会这样
The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...
I m pretty sure I figured it out. I ve definitely grown my understanding, pulled out some hair, and seem to have achieved the behavior I was aiming for.
$.each(["hide"], function () {
var effect = $.fn[this];
$.fn[this] = function (duration, move, callback) {
var speed = duration;
var easing = callback && move || move && !jQuery.isFunction(move) && move;
var _mainElement = $(this);
var _mainElementOriginallyVisible = $(this).is(":visible");
var _visibleChildrenBefore = $(this).find(":visible");
return effect.call(this, speed, easing, function () {
if (_mainElementOriginallyVisible == true) { _mainElement.triggerHandler("madeHidden"); }
_visibleChildrenBefore.each(function () {
if (!($(this).is(":visible"))) {
if ($(this).attr("data-un") !== undefined) { $(this).triggerHandler("madeHidden"); }
}
});
});
};
});
$.each(["show"], function () {
var effect = $.fn[this];
$.fn[this] = function (duration, move, callback) {
var speed = duration;
var easing = callback && move || move && !jQuery.isFunction(move) && move;
var _mainElement = $(this);
var _mainElementOriginallyVisible = $(this).is(":visible");
var _hiddenChildrenBefore = $(this).find(":hidden");
return effect.call(this, speed, easing, function () {
if (_mainElementOriginallyVisible == false) { _mainElement.triggerHandler("madeVisible"); }
_hiddenChildrenBefore.each(function () {
if (!($(this).is(":hidden"))) {
if ($(this).attr("data-un") !== undefined) { $(this).triggerHandler("madeVisible"); }
}
});
});
};
});
我对原始代码最突出的问题似乎与非同步动画有关。 我的代码在触发动画后立即执行,没有等待它完成,所以我刚刚试图隐藏的元素实际上并没有隐藏在随后的代码行中。 etc. etc.
我不得不利用回调参数等待动画完成后再继续执行。
This is the code I ve arrived at. I m sure it can be refined. Please don t hesitate to provide suggestions on how to tighten up this code. I m only a week or so into jQuery and I want to learn.
I recognize there are ways other than show/hide to alter the visibility of elements, and I m fine with the limitation that those methods must be used to trigger the custom events. I ve also applied an intentional restriction that only items with my custom attribute data-un (used to be data-uniquename) will trigger the events.
- 陶德
The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...
I have a div <div id="masterdiv"> which has several child <div>s. Example: <div id="masterdiv"> <div id="childdiv1" /> <div id="childdiv2" /> <div id="...
I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.
I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...
Ok, I m stumped. Basically, this script works fine in FF, but not in IE (6,7 or 8) - in which it returns an "Object doesn t support this property or method" error. Any ideas?: function ...
What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...