1

我被困在为什么这行不通。div用 of 类抓取可见的.open,然后div用of 类抓取 并在其上.edititable附加图像。

请任何帮助都会很棒。

这是我的代码:

$('#imagefiles ul li img').click(function() {
    //Get the source of the image that was clicked
    var img = $(this).attr('src');
    //grab the visible div and the div with class edititable within it and append image
    $(".open:visible.edititable").append('<img src="' + img + '" style="width:30%; height:30%;" ">');
});
4

1 回答 1

0

我认为.open.edititable:visible可能更正确。我不认为你可以在伪选择器之后上课。

虽然我很困惑:

//grab the visible div and the div with class edititable within it and append image

你想要一个.open:visible和一个.edititablediv(2 个 div)还是你想要一个 div 和两个类.open.edititable那也是visible?或者您是否希望子 div 的类.editable位于 div 中的类.open也是visible.

.open.edititable:visible将使用两个类openedititable. .open:visible .edititable将获取具有类的 div ,该类edititable是具有类的可见 div 的子级open

于 2013-02-28T21:48:59.637 回答