Javascript 正在将类添加到此href。。不工作?
我们的网站上有上传功能。和上传的文件,显示链接,点击用户可以看到他们在新窗口上传的文件 我们也使用divbox 我的代码是:Javascript 正在将类添加到此href。。不工作?,javascript,jquery,Javascript,Jquery,我们的网站上有上传功能。和上传的文件,显示链接,点击用户可以看到他们在新窗口上传的文件 我们也使用divbox 我的代码是: $("#uploader" + queueId).html(" <div class='cancel'> <input class='button_cancel' name='removeFile' fileName='" +fileObj.name.replace("'", "%27")+"' type='button'> <
$("#uploader" + queueId).html("
<div class='cancel'>
<input class='button_cancel' name='removeFile' fileName='"
+fileObj.name.replace("'", "%27")+"' type='button'>
</div>
<a class='lightbox' href='" + self.attr("path")
+ fileObj.name.replace("'", "%27") + "'><span class='fileName'>"
+fileObj.name+"</span></a>");
在js中,我们有一个上传程序
$("#uploader" + queueId).html("<div class='cancel'><input class='button_cancel' name='removeFile' fileName='"+fileObj.name.replace("'", "%27")+"' type='button'></div><a class='lightbox' href='" + self.attr("path") + fileObj.name.replace("'", "%27") + "'><span class='fileName'>"+fileObj.name+"</span></a>");
$(“#uploader”+queueId).html(您可能正在执行以下操作:
$('a.lightbox').divbox({ ... })
$("#uploader" + queueId).html("...");
$('#uploader' + queueId).find('a.lightbox').divbox({ /* and whatever options you need */ });
在添加以构建mu is To short的答案之前,您可以这样实现:
$("#uploader" + queueId).html("
<div class='cancel'>
<input class='button_cancel' name='removeFile' fileName='"+fileObj.name.replace("'", "%27")+"' type='button'>
</div>
<a class='lightbox' href='" + self.attr("path")
+ fileObj.name.replace("'", "%27") + "'><span class='fileName'>"
+fileObj.name+"</span></a>")
.find('a.lightbox')
.divbox({ /* and whatever options you need */ });
$(“#上传程序”+queueId).html(“
为延迟道歉。不得不开枪。在divbox js中,我有,$('.lightbox').divbox({caption:false});上传程序js的代码是:$(“#uploader”+queueId).html(@422:对于lightbox与divbox的混淆,我感到抱歉,在你的例子中应该是lightbox
(示例使用divbox
,因此我感到困惑)。重点是,您可能正在绑定DivBox,然后稍后将新内容添加到DOM中。您好,我明白了,我只是不知道如何在DivBox.js加载后将lightbox绑定到事件。您的示例看起来很有希望。但不知道如何实现代码…@422:在您使用$(“#uploader”+queueId.HTML添加新HTML后…)
,您可以在其中找到新添加的
,其中包含$(“#uploader”+queueId)。find('a.lightbox'))
然后将divbox绑定到它。如果我将示例上载到从属域,您认为您可以进一步帮助Mu吗?我没有得到的是/*以及您需要的任何选项*/这是怎么回事?divbox方法需要参数。对于虚构的示例$('.lightbox').divbox({width:200,opacity:0.9})是的,我们终于成功了。这个问题似乎源于Mu在加载dom后绑定事件时所说的话。非常感谢您的努力。
$("#uploader" + queueId).html("...");
$("#uploader" + queueId).html("...");
$('#uploader' + queueId).find('a.lightbox').divbox({ /* and whatever options you need */ });
$("#uploader" + queueId).html("
<div class='cancel'>
<input class='button_cancel' name='removeFile' fileName='"+fileObj.name.replace("'", "%27")+"' type='button'>
</div>
<a class='lightbox' href='" + self.attr("path")
+ fileObj.name.replace("'", "%27") + "'><span class='fileName'>"
+fileObj.name+"</span></a>")
.find('a.lightbox')
.divbox({ /* and whatever options you need */ });