jquery以弹出模式形式切换

时间:2011-03-30 10:19:41

标签: javascript jquery jquery-ui jquery-plugins

我想在弹出模式窗体上的div之间切换。我看到的问题是模态页面上的document.ready()函数,它尝试加载父表单。如果我加载主父表单,它会扭曲整个页面并尝试自动显示。有没有像div.ready()?如何在弹出模式窗体中包含此代码?

在此处切换代码

<html>
<head>
<title>jQuery test page</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#clickMe").click(function() {
$("#textBox").toggle();
});
});
</script>
</head>
  <body>
  <a id="clickMe">Toggle my text</a>
  <br />
  <div id="textBox">This text will be toggled</div>
  </body>

1 个答案:

答案 0 :(得分:0)

是的,像DOM_ELEMENT.ready()这样的表达式存在,并且在您现在面临的情况下非常有用。

<强>更新

我发现这个插件正在做你需要的: jQuery.elementReady()

<强>示例:

1: 加载到特定图像后立即更改特定图像的来源 DOM(在加载整个DOM之前)。

$.elementReady('powerpic', function(){
    this.src = 'powered-by-jquery.png';
});

2: 如果你想拥有jQuery对象而不是常规DOM

element, use the $(this) function.
$.elementReady('header', function(){
    $(this).addClass('fancy');
});

3: 将多个调用链接到$ .elementReady()。

$.elementReady('first',  function(){ $(this).fancify(); })
 .elementReady('second', function(){ $(this).fancify(); });

4: 在回调中使用'$'别名,即使在noConflict模式下也是如此。

jQuery.noConflict();
jQuery.elementReady('header', function($){
    $(this).addClass('fancy');
});

5: 将轮询间隔更改为100毫秒。这只适用于尚未调用$.elementReady()的情况。

$.elementReady.interval_ms = 100;
相关问题