jquery备忘录:Jquery操作集锦及时间插件和日历插件

jackxiang 2011-11-1 10:07 | |
页面开始:
$(document).ready(function(){
...
});

class="no_update" 下所有input操作

    var obj = $('.no_update input').each(function(){
           $(this).attr("disabled","disabled")
    });
    
    select:
    
    var obj = $('.no_update select').each(function(){
        $(this).attr("disabled","disabled")
    });

解析json:
var arr_link = <?php echo json_encode($arr_link)?>;

var arr = arr_link[id];
$.each(arr,function(key,val){
     alert(key+val);
});

隐藏:
$('#product').css("display","none");

去除样式:
$('#product').removeAttr("Style");

清空:
$("#category_id").empty();

追加:
$("<option value='0'>请选择</option>").appendTo("#category_id");

下一个节点
var obj = $(change_obj).next().next();

绑定事件:
$('#text_id').change(function(){
........
});

get by name:
var name = $('input[name^="start_day"]');
    $.each (name,function (key,val){
        alert(val.value);
    });

Select option:
var subregion_id = $('#subregion_id_'+ad_id).get(0);
    subregion_id.options.length = 0;
    subregion_id.options[0] = new Option('请选择',0);
subregion_id.options[i+1] = new Option(result[i].TypeName,result[i].TypeId);

var subregion_id = $('#subregion_id_'+ad_id).val();
var subregion_text=$('#subregion_id_'+ad_id).find("option:selected").text();

ajax 返回:
$.ajax({
            url: '/ajax/i.php',
            data: 'type=get_category&type_id='+type_id,
            type: 'GET',
            dataType: 'json',
            success: function(result){
            if(result){
                for(var i=0; i< result.length; i++){
                    $("<option value='"+result[i].category_id+"'>"+result[i].category_name+"</option>").appendTo("#category_id");
                }
            }
            }
        });
        
绑定时间框:
var cal = Calendar.setup({
        onSelect: function(cal) { cal.hide() },
        showTime: false
    });
    var start_day = $('input[name^="start_day"]');
    $.each (start_day,function (key,val){
        cal.manageFields(val.id, val.id, "%Y-%m-%d");
    });

关键字自动下拉框;
$("#keyword").autocomplete("getkeyword.php?type=get_names", {
        width: 363,
        autoFill: false,
        mustMatch: false,
        selectFirst: false,
        minChars: 0
    });
    $("#keyword").result(function(event, data, formatted) {
        if (data) {
            $("#keyword_id").val(data[1]);
        }
    });
    



来源:blog.sina.com.cn/s/blog_6b7d19300100pvxf.html

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/4765/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!

评论列表
2011-11-20 14:30 | bokig097 Email
我也来顶一下..
分页: 1/1 第一页 1 最后页
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]