2011/04/20

例子 - select in jquery


目的是左面SELECT選擇時, 右面PARENT ITEM跟著一起轉
特別地方是只match option內的html (因為value不能比較) , 而html也不是全等, 只是"match"


jQuery("select#edit-field-category-und").change(function(){ //事件發生
    //一次印出
    var word = jQuery("select#edit-field-category-und option:selected").html();
   // jQuery("#edit-menu-parent option:contains("+word+")").attr('checked',true);
   jQuery("select#edit-menu-parent").children().each(function(){
      if (jQuery(this).text().match(word)){
          //jQuery給法
          jQuery(this).attr("selected","true");
 
      }
    });

});

沒有留言:

發佈留言