我想要class =" hotelname"在课堂上回复文字=" a"和class =" hotelname"是隐藏。那可能吗?我使用jQuery代码,但它无法正常工作。
<form id="" class="" method="GET" action="http://localhost/blue_bucket/county/" enctype="multipart/form-data">
<h2 class="a"></h2>
<?php
foreach ($query as $row)
{
?>
<h3 class="hotelname"><?php echo $hotelnames = $row->hotel; ?></h3>
<div class="book-it-btn">
<button type="submit" name="submit" class="btn btn-default">Apply</button>
</div>
</form>
<?php
}
?>
Jquery的:
jQuery(".a").append(jQuery(".hotelname").html());
答案 0 :(得分:0)
根据我的理解,您希望将.hotelname
类值放入.a
类,然后您想要隐藏.hotelname
类元素?
检查下面的工作代码段
var hotelName = $(".hotelname").text(); $(".a").text(hotelName);
$(document).ready(function() {
var hotelName = $(".hotelname").text();
$(".a").text(hotelName)
$(".hotelname").hide();
})
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<form id="" class="" method="GET" action="http://localhost/blue_bucket/county/" enctype="multipart/form-data">
<h2 class="a"></h2>
<?php
foreach ($query as $row)
{
?>
<h3 class="hotelname">My hotel</h3>
<div class="book-it-btn">
<button type="submit" name="submit" class="btn btn-default">Apply</button>
</div>
</form>
<?php
}
?>
&#13;