首先,我是 Jquery 的新手。
我有这样的图像。我想要的是,当用户单击图像时,它会使图像带有边框。用户可以选择多个图像。选择时所有内容都必须带有边框。单击按钮后,我将获得图像 ID。
<tr><img id="i will put value for db processing"src="urlofimage"</tr>
我怎样才能做到这一点?
你的意思是:
$.fn.hasBorder = function() {
if ((this.outerWidth() - this.innerWidth() > 0) || (this.outerHeight() - this.innerHeight() > 0)){
return true;
}
else{
return false;
}
};
$(document).ready(function() {
var selectedImgsArr = [];
$("img").click(function() {
if($(this).hasBorder()) {
$(this).css("border", "");
//you can remove the id from array if you need to
}
else {
$(this).css("border", "1 px solid red");
selectedImgsArr.push($(this).attr("id")); //something like this
}
});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)