我有問題重新綁定動態創建的對象,從前置。我嘗試了很多東西,但我只能解除綁定。請幫忙。如何綁定()與動態創建的對象
$(document).ready(function(){
$(".newdir").click(function(){
$(".d-exp").prepend("<div id='new' class='fm-dir'><div class='exp-x'></div><div class='fm-name'><input class='nd-text' type='text'></div></div>");
$(".newfile, .paste, .copy, .cut, .rename, .delete, .fileinfo, .visit").css("opacity",".35");
$(".newdir, .newfile, .paste, .copy, .cut, .rename, .delete, .fileinfo, .visit").unbind();
});
$(".ribbon-menu").on("click", ".newfile", function(){
$(".d-exp").prepend("<div id='new' class='fm-fn'><div class='exp-x'></div><div class='fm-name'><input class='nf-text' type='text'></div></div>");
$(".newdir, .paste, .copy, .cut, .rename, .delete, .fileinfo, .visit").css("opacity",".35");
$(".ribbon-menu").unbind();
});
$("div.d-exp").on("click", ".exp-x", function(){
$(".ribbon-menu").bind();
$(".newdir, .newfile, .paste, .copy, .cut, .rename, .delete, .fileinfo, .visit").css("opacity","1");
$("div#new.fm-dir, div#new.fm-fn").remove();
});
});
LIVE ANSWER http://jsfiddle.net/dC344/
什麼版本jQuery?綁定()已棄用。你想綁定什麼? –