Hi I have a function that i want to pass an element to via clicking the element or calling the function with the element as a paramter. This is what I have:
function change_btm_cat(item) {
$( div.prod_matrix ).removeClass( block );
$( div.prod_matrix ).addClass( none );
$( div.prod_matrix# +item.attr( id )).removeClass( none );
$( div.prod_matrix# +item.attr( id )).addClass( block );
$( div.btm_cat ).removeClass( green_grad );
$( div.btm_cat ).addClass( grey_grad );
item.removeClass( grey_grad );
item.addClass( green_grad );
//ps. i know its messy, just testing stuff
}
我可以轻而易举地利用:
$( div.btm_cat ).click(function() {
change_btm_cat($(this));
});
但当我尝试:
$( another.element ).live( click , function() {
change_btm_cat($( div.btm_cat#7 ));
});
这似乎对这项职能没有任何影响。
See jsFiddle for working example: 。