在图像的边框之间切换,并删除其他现有图像的边框 [英] Toggle between borders of a image and remove borders of other existing images

查看:62
本文介绍了在图像的边框之间切换,并删除其他现有图像的边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想选择一张图像并删除其他现有图像的边框

I want to select only one image and remove borders of other existing images

现在可以像这样选择许多图像:

Now many images can be selected like that:

我需要有关选择和取消选择单个图像的帮助.

I want help on select and deselecting single images.

function clickpick(item) {

    for ( var i = 5; i < document.images.length; i++) {

        document.images[i].onclick = function() {

        if (this.style.borderWidth == '5px') {
            selectpic = '';
            $("#display-frame").find("*").css("border", "0");
        } else {
            this.style.border = '5px solid blue';
            selectpic = $(item).attr("url");
        }

    };
}

图像是自动生成的

<div class="mainpic"><img src="';path+=file.filepath+'" class="uploader-thumb-img" style="width: 108px; height: 120px; top: 0px; left: 0px; "/></div>

更新: 我想选择图片的网址,对不起,忘了提及

update: i want to select the url of the image sorry forgot to mention that

推荐答案

解决方案

使用jQuery .toggleClass() 函数.

Solution

Using jQuery .toggleClass() function.

CSS :

img { border: 0; }
img.highlight { border: 5px solid blue; }

JavaScript :

var url;

$('img').click(function (e) {
    $('img.highlight').not(e.target).removeClass('highlight');
    $(this).toggleClass('highlight');
    url = $(this).attr('href');
});​

演示

http://jsfiddle.net/7FAjD/2

这篇关于在图像的边框之间切换,并删除其他现有图像的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆