我有img普通班级
<div debug-id="slide-0" style="width: 800px; height: 356px; top: 0px; left: -800px; position: absolute; overflow: hidden;">
<img class="commonclass" u="image" id="imgid_1" src="upload/img_1.jpg" border="0" style="width: 800px; height: 356px; top: 0px; left: 0px; position: absolute;"></div>
img类名是完全相同但div debug-id不同所以如何调用样式的父div
<div debug-id="slide-1" style="width: 800px; height: 356px; top: 0px; left: 0px; position: absolute; overflow: hidden;">
<img class="commonclass" u="image" id="imgid_2" src="upload/img_2.jpg" border="0" style="width: 800px; height: 356px; top: 0px; left: 0px; position: absolute;"></div>
以及更多
<div debug-id="slide-2" style="width: 800px; height: 356px; top: 0px; left: 0px; position: absolute; overflow: hidden;">
<img class="commonclass" u="image" id="imgid_3" src="upload/img_2.jpg" border="0" style="width: 800px; height: 356px; top: 0px; left: 0px; position: absolute;">
答案 0 :(得分:2)
如果您尝试选择父div,尽管它没有可用的ID和类选择器,只需选择图像并使用如下的parent():
$('img.commonclass').parent();
答案 1 :(得分:0)
如果您希望从属性SELECT
p.*,
CONCAT(IFNULL(GROUP_CONCAT(c_parent...), ''), ',', IFNULL(GROUP_CONCAT(c_direct_parent...), '')),
GROUP_CONCAT(c_child...),
FROM `places` AS p
LEFT JOIN `places_categories_rel` AS rel
ON rel.`place_id` = p.`id`
LEFT JOIN `categories` AS c_direct_parent
ON c_direct_parent.`id` = rel.`category_id`
AND c_direct_parent.`parent_id` IS NULL
LEFT JOIN `categories` AS c_child
ON c_child.`id` = rel.`category_id`
AND c_child.`parent_id` IS NOT NULL
LEFT JOIN `categories` AS c_parent
ON c_parent.`id` = c_child.`parent_id`
GROUP BY p.`id`
获取父div,
debug-id