<script src="../js/jquery-1.3.1.js" type="text/javascript"></script>
$(function () {
var list = document.getElementsByTagName("input");
for (i = 0; i < list.length; i++) {
if (list[i].id.indexOf("address") != -1) {
//这里我想给页面上所有input控件id中包含adderss的控件绑定属性,这里提示不支持方法和属性
document.getElementById(list[i].id).selectCity("#selectItem");
}
}
//test1:
//$("#address").selectCity("#selectItem");
});
求高手决解....
$(function () {
var list = document.getElementsByTagName("input");
for (i = 0; i < list.length; i++) {
if (list[i].id.indexOf("address") != -1) {
//这里我想给页面上所有input控件id中包含adderss的控件绑定属性,这里提示不支持方法和属性
document.getElementById(list[i].id).selectCity("#selectItem");
}
}
//test1:
//$("#address").selectCity("#selectItem");
});
求高手决解....
$("input[id*='address']").attr("","");
或者
$("input[id*='address']").data("","");
想这样还是无法实现$("#address").selectCity("#selectItem");像这样的绑定的效果
$("input[id*='address']").each(function(){
$(this).selectCity("#selectItem");
});这样呢
还是不行啊////..$("input[id='address']").selectCity("#selectItem");这样都不行,为什么。。
jQuery.fn.selectCity = function(targetId) {
var _seft = this;
var targetId = targetId; this.click(function(){
var A_top = $(this).offset().top + $(this).outerHeight(true); // 1
var A_left = $(this).offset().left;
targetId.bgiframe();
targetId.show().css({"position":"absolute","top":A_top+"px" ,"left":A_left+"px"});
}); targetId.find("#selectItemClose").click(function(){
targetId.hide();
}); targetId.find("#selectSub :checkbox").click(function(){
targetId.find(":checkbox").attr("checked",false);
$(this).attr("checked",true);
_seft.val( $(this).val() );
targetId.hide();
}); $(document).click(function(event){
if(event.target.id!=_seft.selector.substring(1)){
targetId.hide();
}
}); targetId.click(function(e){
e.stopPropagation(); // 2
}); return this;
}
$(function(){
$("input[id*='address']").each(function(){
$(this).selectCity("#selectItem");
});
});