我有一个页面上有很多链接,我只需要打开几个jQuery对话框。 如何使用类而不是id打开它们?
以下是我的脚本:
<script>
// increase the default animation speed to exaggerate the effect
$.fx.speeds._default = 1000;
$(function() {
$( "#selectFolder" ).dialog({position:['middle',60],
open: function(event, ui) {
jQuery('.ui-dialog-titlebar-close').removeClass("ui-dialog-titlebar-close").html('<span style="float:right;"><img src="../images/x.png" /></span>');
},
dialogClass: 'ui-widget-shadow',
modal: true,
autoOpen: false,
width: '650px',
close: function(ev, ui) {$(this).close();}
});
$( "#selectFolderOpen" ).click(function() {
$( "#selectFolder" ).dialog( "open" );
return false;
});
});
</script>
<div style="display:none;">
<div id="selectFolder" title="Select Folder">
<div style="display:block;">
<!--#include file="sidebar_modal_questions_folder_select.asp"-->
</div>
</div>
</div>
这里有一个目前有效的例子:
<a href="#" class="buttonintable" id="selectFolderOpen">Select Folder</a>
我希望它能像这样工作:
<a href="#" class="buttonintable selectFolderOpen">Select Folder</a>
那样我就不必为每个要打开的链接都设置ID。我知道你使用('#selector')来表示ID,而('.selector')表示类 - 但我无法让它起作用。需要帮助吗?
a.selectFolderOpen
中的a
可以删除。也许以后你想把它变成一个 span 或者其他什么东西,我倾向于只使用类名而不是过于狭隘的作用域。 :p - nzifnab