2017-05-02 17 views
-3

私はclass = "a"とclass = "hotelname"のclass = "hotelname"エコーテキストを非表示にしたいです。それは可能ですか? jQueryコードを使用しましたが、動作しません。Divのテキストは他のdivに置き換えます

<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()); 
+2

質問以下の作業スニペットを確認してください。より具体的なものをあなたが望むものにする。私はあなたの質問を理解することができません。 –

+0

あなたは複数のクラスを取得します –

答えて

0

あなたは、あなたが.hotelname class要素を非表示にする.aクラスに入れて.hotelnameクラス値をしたいですか?

はよく指定されていない中

var hotelName = $(".hotelname").text(); 

     $(".a").text(hotelName); 

$(document).ready(function() { 
 
    var hotelName = $(".hotelname").text(); 
 
    
 
    $(".a").text(hotelName) 
 
    $(".hotelname").hide(); 
 

 
})
<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 
 
    } 
 
    ?>