我有一个有两个值的RadionButtonList,在单击时,我必须隐藏页面上的一些元素。
我得到了以下代码,它会在单击某个RadionButton时触发。如何在页面的页面加载中调用此函数?
$(document).ready(function () {
$('#<%= columnsRoundPanel.FindControl("rdlClickOrder").ClientID %> input').click(function () {
var clickOrder = $(this).val();
$('#<%= chkColumnList.ClientID %> input').each(function (i) {
var index = ($(this).next('label').text().indexOf(clickOrder));
if ((index == -1) && ($(this).next('label').text() != 'Cost' && $(this).next('label').text() != 'Clicks' && $(this).next('label').text() != 'Impressions')) {
$(this).css('display', 'none');
$(this).next('label').css('display', 'none');
} else {
$(this).css('display', 'inline');
$(this).next('label').css('display', 'inline');
}
});
});
});发布于 2011-08-15 22:39:53
您可以在注册处理程序后立即触发click事件:
$('#<%= columnsRoundPanel.FindControl("rdlClickOrder").ClientID %> input')
.click(function() {
// Your handler...
}).click();发布于 2011-08-15 22:37:31
试一试
$('#<%= columnsRoundPanel.FindControl("rdlClickOrder").ClientID %> input').click();在你的代码之后
发布于 2011-08-15 22:39:39
$(document).ready(function () {
$('#<%= columnsRoundPanel.FindControl("rdlClickOrder").ClientID %> input').click(function () {
var clickOrder = $(this).val();
$('#<%= chkColumnList.ClientID %> input').each(function (i) {
var index = ($(this).next('label').text().indexOf(clickOrder));
if ((index == -1) && ($(this).next('label').text() != 'Cost' && $(this).next('label').text() != 'Clicks' && $(this).next('label').text() != 'Impressions')) {
$(this).css('display', 'none');
$(this).next('label').css('display', 'none');
} else {
$(this).css('display', 'inline');
$(this).next('label').css('display', 'inline');
}
});
}).click();
});https://stackoverflow.com/questions/7066216
复制相似问题