这听起来比实际简单得多。我无法使用 jQuery 修改 DOM,因为每个项目及其详细信息都是使用 PHP 从数据库中填充的。
理论上我想做的事情很简单,但我做不到。例如我想要的是:
如果单击项目 1001,则隐藏所有其他项目并显示有关项目 1001 的更多详细信息。
这是我第二次在这个问题上寻求帮助,似乎没有人知道这个问题的答案。我已经改写了我的问题并再次尝试,并且非常感谢您的帮助。即使你能指出我正确的方向,我也会去研究它。TBH 我完全不知道从哪里开始。
谢谢
<script>
$(".1001").click(function(){
$("#images1").remove();
$("#images2").show();
});
</script>
<section class="catalogListing">
<?php $load_content->load_content("1001");?>
<div class="dresses">
<a class="1001" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?><br />Was:<strike>£175.00</strike></p>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1002");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?><br />Was:<strike>£150.00</strike></p>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
<p class="p4"><font>Out of stock</font></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1003");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?><br />Was:<strike>£150.00</strike></p>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
<p class="p4"><font>Out of stock</font></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1004");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1005");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?><br />Was:<strike>£150.00</strike></p>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1006");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1007");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1008");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
<p class="p4"><font>Out of stock</font></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1009");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
</section><!---End of first nine items--->
<section id="secondNineItems">
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1010");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1011");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1012");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1013");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<!---Items with the class "tunics" are below--->
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1014");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1015");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<!---Items with the class "tops" are below--->
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1016");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
<p class="p4"><font>Out of stock</font></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1017");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1018");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
<p class="p4"><font>Out of stock</font></p>
</div>
</section>
</section><!---End of second nine items--->
<section id="thirdNineItems">
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1019");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1020");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1021");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1022");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1023");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
</div>
</section>
<section class="catalogListing">
<div class="dresses">
<?php $load_content->load_content("1024");?>
<a class="a3" href="#">
<figure><img src="<?php echo $load_content->getImgMedium();?>" /></figure>
<p class="listing"><?php echo $load_content->getTitle();?></p></a>
<p class="listingSub">Artist:<?php echo $load_content->getArtist();?>
<p class="p4"><strong>Now: £<span class="price"><?php echo $load_content->getPrice();?></span></strong></p>
<p class="p4"><font>Out of stock</font></p>
</div>
</section>
</section><!---End of third nine items--->
</article><!---End of article:ShopContent--->
</article><!---End of article:ShopWrapper--->
</article><!---End of article:main--->
<!---Main Content Area clothes--->
<article id="clothes1">
<p class="p2"><a href="index.php" class="a2">HOME ></a> <a href="shop.php" class="a2">SHOP ></a> <strong>CLOTHES 1</strong></p>
<!--- Load images --->
<section id="images1" style="width:400px; float:left; height:auto;">
<p><?php $load_content->load_content('1002');?></p>
<a href="<?php echo $load_content->getImgLarge1();?>" class="zoom">
<img src="<?php echo $load_content->getImgLarge1();?>" width="375" height="568" alt="arrows"></a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="<?php echo $load_content->getImgSmall1();?>" width="64" height="100"/>
</a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="<?php echo $load_content->getImgSmall2();?>" width="64" height="100"/>
</a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="<?php echo $load_content->getImgSmall3();?>" width="64" height="100"/>
</a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="<?php echo $load_content->getImgSmall4();?>" width="64" height="100"/>
</a>
</section>
<!--- Load images --->
<section id="images2" style="width:400px; float:left; height:auto;">
<p><?php $load_content->load_content('1001');?></p>
<a href="<?php echo $load_content->getImgLarge1();?>" class="zoom">
<img src="<?php echo $load_content->getImgLarge1();?>" width="375" height="568" alt="arrows"></a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="<?php echo $load_content->getImgSmall1();?>" width="64" height="100"/>
</a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="<?php echo $load_content->getImgSmall2();?>" width="64" height="100"/>
</a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="<?php echo $load_content->getImgSmall3();?>" width="64" height="100"/>
</a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="<?php echo $load_content->getImgSmall4();?>" width="64" height="100"/>
</a>
</section>
PHP 生成的 HTML 代码:
<section id="images2" style="width:400px; float:left; height:auto;">
<p></p>
<a href="images/Catalog/Largest/aof_14102_amorous_arrows.jpg" class="zoom">
<img src="images/Catalog/Largest/aof_14102_amorous_arrows.jpg" width="375" height="568" alt="arrows"></a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="images/Catalog/Small/aof_14102_amorous_arrows.jpg" width="64" height="100">
</a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="images/Catalog/Small/aof_14175_amorous_arrows_side_back_view.jpg" width="64" height="100">
</a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="images/Catalog/Small/aof_14077_amorous_arrows_other_view.jpg" width="64" height="100">
</a>
<a href="#">
<img class="thumbnails" title="Click to enlarge" src="images/Catalog/Small/amorous_arrows.jpg" width="64" height="100">
</a>
</section>